[][src]Struct futures_ringbuf::RingBuffer

pub struct RingBuffer<T: Sized + Copy> { /* fields omitted */ }

A RingBuffer that implements AsyncRead and AsyncWrite from the futures library.

Methods

impl<T: Sized + Copy> RingBuffer<T>[src]

pub fn new(size: usize) -> Self[src]

Create a new RingBuffer with a defined capacity. Note that capacity != length, similar to Vec.

pub fn capacity(&self) -> usize[src]

The total capacity of the buffer

pub fn is_empty(&self) -> bool[src]

Whether there is no data at all in the buffer.

pub fn is_full(&self) -> bool[src]

Whether the buffer is completely full.

pub fn len(&self) -> usize[src]

The length of the data in the buffer.

pub fn remaining(&self) -> usize[src]

How much free space there is left in the container. On empty, remaining == capacity

Trait Implementations

impl<T: Sized + Copy> From<(Producer<T>, Consumer<T>)> for RingBuffer<T>[src]

The compiler cannot verify that the producer/consumer are from the same RingBuffer object. Obviously if you abuse this things won't work as expected.

I added this so you can seed a buffer before passing it to futures_ringbuf.

impl<T: Sized + Copy> From<RingBuffer<T>> for RingBuffer<T>[src]

impl<T: Sized + Copy> Debug for RingBuffer<T>[src]

impl AsyncRead for RingBuffer<u8>[src]

fn poll_read(
    self: Pin<&mut Self>,
    cx: &mut Context,
    dst: &mut [u8]
) -> Poll<Result<usize, Error>>
[src]

Will return Poll::Pending when the buffer is empty. Will be woken up by the AsyncWrite impl when new data is written.

When the buffer (for network simulation) is closed and empty, this will return Poll::Ready( Ok(0) ).

This method is infallible.

impl AsyncWrite for RingBuffer<u8>[src]

fn poll_write(
    self: Pin<&mut Self>,
    cx: &mut Context,
    src: &[u8]
) -> Poll<Result<usize, Error>>
[src]

Will return Poll::Pending when the buffer is full. AsyncRead impl will wake up this task when new place is made. This method returns a io::ErrorKind::NotConnected error if called after poll_close.

fn poll_flush(
    self: Pin<&mut Self>,
    _cx: &mut Context
) -> Poll<Result<(), Error>>
[src]

We are always flushed, this is a noop. This method is infallible.

fn poll_close(
    self: Pin<&mut Self>,
    _cx: &mut Context
) -> Poll<Result<(), Error>>
[src]

Closes the stream. After this no more data can be send into it. This method is infallible.

Auto Trait Implementations

impl<T> Send for RingBuffer<T> where
    T: Send

impl<T> Sync for RingBuffer<T> where
    T: Send

impl<T> Unpin for RingBuffer<T>

impl<T> !UnwindSafe for RingBuffer<T>

impl<T> !RefUnwindSafe for RingBuffer<T>

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]