[][src]Struct futures_ringbuf::Endpoint

pub struct Endpoint { /* fields omitted */ }

Represents a network endpoint. This is for duplex connection mocking. Each direction has a separate ringbuffer and one buffer's readhalf is connected to the other buffer's writehalf in order to simulate a duplex connection.

The main way to create this is to call Endpoint::pair which returns a tuple of endpoints, and which let's you specify the buffer size for each direction.

Endpoint implements AsyncRead/AsyncWrite so you can feed it to interfaces that need those combined in a single type.

By setting the buffer size precisely, one can simulate back pressure. Endpoint will return Pending on writes when full and on reads when empty.

When calling close on an endpoint, any further writes on that endpoint will return std::io::ErrorKind::NotConnected and any reads on the other endpoint will continue to empty the buffer and then return Ok(0). Ok(0) means no new data will ever appear, unless you passed in a zero sized buffer.

Methods

impl Endpoint[src]

pub fn pair(a_buf: usize, b_buf: usize) -> (Endpoint, Endpoint)[src]

Create a pair of endpoints, specifying the buffer size for each one. The buffer size corresponds to the buffer the respective endpoint writes to. The other will read from this one.

Trait Implementations

impl Debug for Endpoint[src]

impl AsyncRead for Endpoint[src]

impl AsyncWrite for Endpoint[src]

Auto Trait Implementations

impl Send for Endpoint

impl Sync for Endpoint

impl Unpin for Endpoint

impl !UnwindSafe for Endpoint

impl !RefUnwindSafe for Endpoint

Blanket Implementations

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

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

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.

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

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

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

impl<R> AsyncReadExt for R where
    R: AsyncRead + ?Sized
[src]

impl<W> AsyncWriteExt for W where
    W: AsyncWrite + ?Sized
[src]