[]Struct aiowrap::DequeReader

pub struct DequeReader<R> { /* fields omitted */ }

An interface like io::BufReader, but extra data can be repeatedly added.

let mut m = DequeReader::new(io::Cursor::new(b"hello world"));
// gather more and more data
while m.read_more().await.expect("no io errors") {
    // until we find an 'r'
    if let Some(r) = m.buffer().iter().position(|&c| c == b'r') {
        // then discard everything up to that point
        Pin::new(&mut m).consume(r);
        return;
    }
}
panic!("reached eof")

Methods

impl<R> DequeReader<R>[src]

pub fn new(inner: R) -> DequeReader<R>[src]

Wrap a reader, without allocating a buffer. The buffer will be allocated, and grown, on use.

pub fn with_capacity(inner: R, n: usize) -> DequeReader<R>[src]

Wrap a reader, pre-allocating a buffer of a specific size. The buffer will be grown on use.

Note: SliceDeque has stringent, platform dependent rules around the buffer size, so the resulting buffer size may be wildly different.

pub fn get_ref(&self) -> &R[src]

Gets a reference to the underlying reader.

It is inadvisable to directly read from the underlying reader.

pub fn get_mut(&mut self) -> &mut R[src]

Gets a mutable reference to the underlying reader.

It is inadvisable to directly read from the underlying reader.

pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut R>[src]

Gets a pinned mutable reference to the underlying reader.

It is inadvisable to directly read from the underlying reader.

pub fn into_inner(self) -> R[src]

Consumes this, returning the underlying reader.

Note that any leftover data in the internal buffer is lost.

impl<R: AsyncRead> DequeReader<R>[src]

pub fn poll_read_more(
    self: Pin<&mut Self>,
    cx: &mut Context
) -> Poll<Result<bool>>
[src]

Attempt a large read against the inner reader.

If a byte could not be read as we are at the end of the stream, return false.

pub fn buffer(&self) -> &[u8][src]

Access the inner buffer directly, without attempting any reads.

impl<R: Unpin + AsyncRead> DequeReader<R>[src]

pub async fn read_more<'_>(&'_ mut self) -> Result<bool>[src]

Resolves when we can read at least one extra byte into the inner reader, typically many more, returning true until we are at eof.

Trait Implementations

impl<R: AsyncRead> AsyncBufRead for DequeReader<R>[src]

impl<R: AsyncRead> AsyncRead for DequeReader<R>[src]

impl<W: AsyncWrite> AsyncWrite for DequeReader<W>[src]

impl<'__pin, R> Unpin for DequeReader<R> where
    __Origin<'__pin, R>: Unpin

Auto Trait Implementations

impl<R> RefUnwindSafe for DequeReader<R> where
    R: RefUnwindSafe

impl<R> Send for DequeReader<R> where
    R: Send

impl<R> Sync for DequeReader<R> where
    R: Sync

impl<R> UnwindSafe for DequeReader<R> where
    R: UnwindSafe

Blanket Implementations

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

impl<R> AsyncBufReadExt for R where
    R: AsyncBufRead + ?Sized
[src]

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

impl<W> AsyncWriteExt for W where
    W: AsyncWrite + ?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, 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.