[][src]Struct solicit::http::WindowSize

pub struct WindowSize(_);

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.

Implementations

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 solicit::http::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 solicit::http::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 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 Clone for WindowSize[src]

impl Copy for WindowSize[src]

impl Debug for WindowSize[src]

impl PartialEq<WindowSize> for WindowSize[src]

impl StructuralPartialEq for WindowSize[src]

Auto Trait Implementations

impl RefUnwindSafe for WindowSize

impl Send for WindowSize

impl Sync for WindowSize

impl Unpin for WindowSize

impl UnwindSafe for WindowSize

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.