From 728e5d8395d74e72be86b5fad75acaa6fb219bc7 Mon Sep 17 00:00:00 2001 From: ozpv <39195175+ozpv@users.noreply.github.com> Date: Sat, 16 May 2026 22:42:51 -0500 Subject: account for latency --- src/window_size.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/window_size.rs') 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 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 { + pub fn iter() -> impl Iterator { [ Self::Size128, Self::Size256, -- cgit v1.2.3