[−][src]Struct futures_ringbuf::RingBuffer
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 RingBuffercapacity != 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]
fn from(buffer: SyncRingBuffer<T>) -> Self
[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]
self: Pin<&mut Self>,
cx: &mut Context,
dst: &mut [u8]
) -> Poll<Result<usize, Error>>
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.
fn poll_read_vectored(
self: Pin<&mut Self>,
cx: &mut Context,
bufs: &mut [IoSliceMut]
) -> Poll<Result<usize, Error>>
[src]
self: Pin<&mut Self>,
cx: &mut Context,
bufs: &mut [IoSliceMut]
) -> Poll<Result<usize, Error>>
impl AsyncWrite for RingBuffer<u8>
[src]
fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context,
src: &[u8]
) -> Poll<Result<usize, Error>>
[src]
self: Pin<&mut Self>,
cx: &mut Context,
src: &[u8]
) -> Poll<Result<usize, Error>>
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]
self: Pin<&mut Self>,
_cx: &mut Context
) -> Poll<Result<(), Error>>
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]
self: Pin<&mut Self>,
_cx: &mut Context
) -> Poll<Result<(), Error>>
Closes the stream. After this no more data can be send into it. This method is infallible.
fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context,
bufs: &[IoSlice]
) -> Poll<Result<usize, Error>>
[src]
self: Pin<&mut Self>,
cx: &mut Context,
bufs: &[IoSlice]
) -> Poll<Result<usize, Error>>
Auto Trait Implementations
impl<T> Send for RingBuffer<T> where
T: Send,
T: Send,
impl<T> Sync for RingBuffer<T> where
T: Send,
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]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<R> AsyncReadExt for R where
R: AsyncRead + ?Sized,
[src]
R: AsyncRead + ?Sized,
fn chain<R>(self, next: R) -> Chain<Self, R> where
R: AsyncRead,
[src]
R: AsyncRead,
fn read(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
fn read_vectored(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectored<'a, Self> where
Self: Unpin,
[src]
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectored<'a, Self> where
Self: Unpin,
fn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
fn read_to_end(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
fn read_to_string(&'a mut self, buf: &'a mut String) -> ReadToString<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
fn split(self) -> (ReadHalf<Self>, WriteHalf<Self>) where
Self: AsyncWrite,
[src]
Self: AsyncWrite,
fn take(self, limit: u64) -> Take<Self>
[src]
impl<W> AsyncWriteExt for W where
W: AsyncWrite + ?Sized,
[src]
W: AsyncWrite + ?Sized,
fn flush(&mut self) -> Flush<Self> where
Self: Unpin,
[src]
Self: Unpin,
fn close(&mut self) -> Close<Self> where
Self: Unpin,
[src]
Self: Unpin,
fn write(&'a mut self, buf: &'a [u8]) -> Write<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
fn write_vectored(
&'a mut self,
bufs: &'a [IoSlice<'a>]
) -> WriteVectored<'a, Self> where
Self: Unpin,
[src]
&'a mut self,
bufs: &'a [IoSlice<'a>]
) -> WriteVectored<'a, Self> where
Self: Unpin,
fn write_all(&'a mut self, buf: &'a [u8]) -> WriteAll<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
fn into_sink<Item>(self) -> IntoSink<Self, Item> where
Item: AsRef<[u8]>,
[src]
Item: AsRef<[u8]>,