pub struct WindowSize(pub i32);
The struct represents the size of a flow control window.
It exposes methods that allow the manipulation of window sizes, such that they can never
overflow the spec-mandated upper bound.
Tries to increase the window size by the given delta. If the WindowSize would overflow the
maximum allowed value (2^31 - 1), returns an error case. If the increase succeeds, returns
Ok
.
use httpbis::solicit::WindowSize;
let mut window_size = WindowSize::new(65_535);
assert_eq!(window_size.size(), 65_535);
assert!(window_size.try_increase(100).is_ok());
assert_eq!(window_size.size(), 65_635);
assert!(window_size.try_increase(0x7fffffff).is_err());
assert_eq!(window_size.size(), 65_635);
Tries to decrease the size of the window by the given delta.
There are situations where the window size should legitimately be allowed to become
negative, so the only situation where the result is an error is if the window size would
underflow, as this would definitely cause the peers to lose sync.
use httpbis::solicit::WindowSize;
let mut window_size = WindowSize::new(65_535);
assert_eq!(window_size.size(), 65_535);
assert!(window_size.try_decrease(100).is_ok());
assert_eq!(window_size.size(), 65_435);
assert!(window_size.try_decrease(0x7fffffff).is_ok());
assert_eq!(window_size.size(), -2147418212);
assert!(window_size.try_decrease(0x7fffffff).is_err());
assert_eq!(window_size.size(), -2147418212);
Creates a new WindowSize
with the given initial size.
Returns the current size of the window.
The size is actually allowed to become negative (for instance if the peer changes its
intial window size in the settings); therefore, the return is an i32
.
Formats the value using the given formatter. Read more
Performs copy-assignment from source
. Read more
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
Formats the value using the given formatter. Read more