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]

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);

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);

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.

Trait Implementations

impl Debug for WindowSize
[src]

Formats the value using the given formatter. Read more

impl Copy for WindowSize
[src]

impl Clone for WindowSize
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl PartialEq for WindowSize
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Display for WindowSize
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for WindowSize

impl Sync for WindowSize