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]
pub fn try_increase(&mut self, delta: u32) -> Result<(), ()>
[src]
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
.
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);
pub fn try_decrease(&mut self, delta: i32) -> Result<(), ()>
[src]
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);
pub fn try_decrease_to_positive(&mut self, delta: i32) -> Result<(), ()>
[src]
pub fn new(size: i32) -> WindowSize
[src]
Creates a new WindowSize
with the given initial size.
pub fn size(&self) -> i32
[src]
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]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Copy for WindowSize
[src]
impl Clone for WindowSize
[src]
fn clone(&self) -> WindowSize
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl PartialEq for WindowSize
[src]
fn eq(&self, __arg_0: &WindowSize) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &WindowSize) -> bool
[src]
This method tests for !=
.