[−]Struct aiowrap::DequeReader
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]
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<bool>>
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]
fn poll_fill_buf<'a>(
self: Pin<&'a mut Self>,
cx: &mut Context
) -> Poll<Result<&'a [u8]>>
[src]
self: Pin<&'a mut Self>,
cx: &mut Context
) -> Poll<Result<&'a [u8]>>
fn consume(self: Pin<&mut Self>, amt: usize)
[src]
impl<R: AsyncRead> AsyncRead for DequeReader<R>
[src]
fn poll_read(
self: Pin<&mut Self>,
cx: &mut Context,
buf: &mut [u8]
) -> Poll<Result<usize>>
[src]
self: Pin<&mut Self>,
cx: &mut Context,
buf: &mut [u8]
) -> Poll<Result<usize>>
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<W: AsyncWrite> AsyncWrite for DequeReader<W>
[src]
fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context,
buf: &[u8]
) -> Poll<Result<usize>>
[src]
self: Pin<&mut Self>,
cx: &mut Context,
buf: &[u8]
) -> Poll<Result<usize>>
fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context,
bufs: &[IoSlice]
) -> Poll<Result<usize>>
[src]
self: Pin<&mut Self>,
cx: &mut Context,
bufs: &[IoSlice]
) -> Poll<Result<usize>>
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<()>>
[src]
fn poll_close(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<()>>
[src]
impl<'__pin, R> Unpin for DequeReader<R> where
__Origin<'__pin, R>: Unpin,
__Origin<'__pin, R>: Unpin,
Auto Trait Implementations
impl<R> RefUnwindSafe for DequeReader<R> where
R: RefUnwindSafe,
R: RefUnwindSafe,
impl<R> Send for DequeReader<R> where
R: Send,
R: Send,
impl<R> Sync for DequeReader<R> where
R: Sync,
R: Sync,
impl<R> UnwindSafe for DequeReader<R> where
R: UnwindSafe,
R: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<R> AsyncBufReadExt for R where
R: AsyncBufRead + ?Sized,
[src]
R: AsyncBufRead + ?Sized,
fn read_until(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8>
) -> ReadUntil<'a, Self> where
Self: Unpin,
[src]
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8>
) -> ReadUntil<'a, Self> where
Self: Unpin,
fn read_line(&'a mut self, buf: &'a mut String) -> ReadLine<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
fn lines(self) -> Lines<Self>
[src]
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]>,
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> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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>,