Struct httpbis::solicit::WindowSize
[−]
[src]
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.
Methods
impl WindowSize
[src]
fn try_increase(&mut self, delta: u32) -> Result<(), ()>
Tries to increase the window size by the given delta. If the WindowSize would overflow the
maximum allowed value (231 - 1), returns an error case. If the increase succeeds, returns
Ok
.
Examples
use httpbis::solicit::WindowSize; let mut window_size = WindowSize::new(65_535); assert_eq!(window_size.size(), 65_535); // An increase within the bounds... assert!(window_size.try_increase(100).is_ok()); assert_eq!(window_size.size(), 65_635); // An increase that would overflow assert!(window_size.try_increase(0x7fffffff).is_err()); assert_eq!(window_size.size(), 65_635);
fn try_decrease(&mut self, delta: i32) -> Result<(), ()>
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.
Example
use httpbis::solicit::WindowSize; let mut window_size = WindowSize::new(65_535); assert_eq!(window_size.size(), 65_535); // A decrease... assert!(window_size.try_decrease(100).is_ok()); assert_eq!(window_size.size(), 65_435); // A decrease that does not underflow assert!(window_size.try_decrease(0x7fffffff).is_ok()); assert_eq!(window_size.size(), -2147418212); // A decrease that *would* underflow assert!(window_size.try_decrease(0x7fffffff).is_err()); assert_eq!(window_size.size(), -2147418212);
fn try_decrease_to_positive(&mut self, delta: i32) -> Result<(), ()>
fn new(size: i32) -> WindowSize
Creates a new WindowSize
with the given initial size.
fn size(&self) -> i32
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
.
Trait Implementations
impl Debug for WindowSize
[src]
impl Copy for WindowSize
[src]
impl Clone for WindowSize
[src]
fn clone(&self) -> WindowSize
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl PartialEq for WindowSize
[src]
fn eq(&self, __arg_0: &WindowSize) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &WindowSize) -> bool
This method tests for !=
.