summaryrefslogtreecommitdiff
path: root/src/window_size.rs
diff options
context:
space:
mode:
authorozpv <39195175+ozpv@users.noreply.github.com>2026-05-16 22:42:51 -0500
committerGitHub <noreply@github.com>2026-05-16 22:42:51 -0500
commit728e5d8395d74e72be86b5fad75acaa6fb219bc7 (patch)
tree3d29f165048af2ddc1f068c0a7675f3d7da510d6 /src/window_size.rs
parent12ae71759075a98deed5728d972c50e7131c726f (diff)
account for latency
Diffstat (limited to 'src/window_size.rs')
-rw-r--r--src/window_size.rs23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/window_size.rs b/src/window_size.rs
index 0c1ef08..9d3f66b 100644
--- a/src/window_size.rs
+++ b/src/window_size.rs
@@ -1,3 +1,5 @@
+/// The max value of the custom window size is u32::MAX.
+/// That's because it's the maximum latency one can report.
#[derive(Debug, PartialEq)]
pub enum WindowSize {
Size128,
@@ -14,6 +16,8 @@ pub enum WindowSize {
impl From<usize> for WindowSize {
fn from(item: usize) -> Self {
+ let item = item.clamp(0, u32::MAX as usize);
+
match item {
128 => Self::Size128,
256 => Self::Size256,
@@ -45,7 +49,22 @@ impl WindowSize {
}
}
- pub fn value(&self) -> usize {
+ pub fn into_inner(self) -> usize {
+ match self {
+ Self::Size128 => 128,
+ Self::Size256 => 256,
+ Self::Size512 => 512,
+ Self::Size1024 => 1024,
+ Self::Size2048 => 2048,
+ Self::Size4096 => 4096,
+ Self::Size8192 => 8192,
+ Self::Size16384 => 16384,
+ Self::Size32768 => 32768,
+ Self::Custom(x) => x,
+ }
+ }
+
+ pub fn inner(&self) -> usize {
match self {
Self::Size128 => 128,
Self::Size256 => 256,
@@ -60,7 +79,7 @@ impl WindowSize {
}
}
- pub fn into_iter() -> impl Iterator<Item = Self> {
+ pub fn iter() -> impl Iterator<Item = Self> {
[
Self::Size128,
Self::Size256,