pub struct AsyncMapReader<'a, R> { /* private fields */ }
Expand description
A wrapper around an AsyncRead
that allows for data processing
before the actual I/O operation.
This struct buffers the data read from the underlying reader and applies a mapping function to the data before returning it. It is designed to optimize reads by using a buffer of a specified size (default is 8KB).
The buffer size also acts as a threshold for the length of data passed to the mapping function, and will be gauranteed to be equal the capacity of the underlying buffer, until the last read operation, where it may be smaller.
Implementations§
Source§impl<'a, R> AsyncMapReader<'a, R>where
R: AsyncRead,
impl<'a, R> AsyncMapReader<'a, R>where
R: AsyncRead,
Sourcepub fn new(reader: R, process_fn: impl MapReadFn + 'a) -> Self
pub fn new(reader: R, process_fn: impl MapReadFn + 'a) -> Self
Create a new wrapper around an async reader with a processing function
Sourcepub fn with_capacity(
reader: R,
process_fn: impl MapReadFn + 'a,
capacity: usize,
) -> Self
pub fn with_capacity( reader: R, process_fn: impl MapReadFn + 'a, capacity: usize, ) -> Self
Create a new wrapper with a specific initial buffer capacity
Sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Consume the wrapper and return the inner reader
Trait Implementations§
Source§impl<'a, R: AsyncRead> AsyncBufRead for AsyncMapReader<'a, R>
impl<'a, R: AsyncRead> AsyncBufRead for AsyncMapReader<'a, R>
Source§impl<'a, R> AsyncRead for AsyncMapReader<'a, R>where
R: AsyncRead,
impl<'a, R> AsyncRead for AsyncMapReader<'a, R>where
R: AsyncRead,
impl<'__pin, 'a, R> Unpin for AsyncMapReader<'a, R>where
PinnedFieldsOf<__Origin<'__pin, 'a, R>>: Unpin,
Auto Trait Implementations§
impl<'a, R> Freeze for AsyncMapReader<'a, R>where
R: Freeze,
impl<'a, R> !RefUnwindSafe for AsyncMapReader<'a, R>
impl<'a, R> !Send for AsyncMapReader<'a, R>
impl<'a, R> !Sync for AsyncMapReader<'a, R>
impl<'a, R> !UnwindSafe for AsyncMapReader<'a, R>
Blanket Implementations§
Source§impl<R> AsyncBufReadExt for Rwhere
R: AsyncBufRead + ?Sized,
impl<R> AsyncBufReadExt for Rwhere
R: AsyncBufRead + ?Sized,
Source§fn fill_buf(&mut self) -> FillBuf<'_, Self>where
Self: Unpin,
fn fill_buf(&mut self) -> FillBuf<'_, Self>where
Self: Unpin,
Returns the contents of the internal buffer, filling it with more data if empty. Read more
Source§fn read_until<'a>(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8>,
) -> ReadUntilFuture<'a, Self>where
Self: Unpin,
fn read_until<'a>(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8>,
) -> ReadUntilFuture<'a, Self>where
Self: Unpin,
Source§fn read_line<'a>(&'a mut self, buf: &'a mut String) -> ReadLineFuture<'a, Self>where
Self: Unpin,
fn read_line<'a>(&'a mut self, buf: &'a mut String) -> ReadLineFuture<'a, Self>where
Self: Unpin,
Reads all bytes and appends them into
buf
until a newline (the 0xA byte) or EOF is found. Read moreSource§impl<'a, R> AsyncMapRead<'a, R> for Rwhere
R: AsyncRead,
impl<'a, R> AsyncMapRead<'a, R> for Rwhere
R: AsyncRead,
Source§fn map_with_capacity(
self,
f: impl MapReadFn + 'a,
capacity: usize,
) -> AsyncMapReader<'a, R>
fn map_with_capacity( self, f: impl MapReadFn + 'a, capacity: usize, ) -> AsyncMapReader<'a, R>
Maps the underlying reader to an
AsyncMapReader
using the provided mapping function
and a specified buffer capacity. Read moreSource§impl<R> AsyncReadExt for R
impl<R> AsyncReadExt for R
Source§fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self>where
Self: Unpin,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self>where
Self: Unpin,
Reads some bytes from the byte stream. Read more
Source§fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>],
) -> ReadVectoredFuture<'a, Self>where
Self: Unpin,
fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>],
) -> ReadVectoredFuture<'a, Self>where
Self: Unpin,
Source§fn read_to_end<'a>(
&'a mut self,
buf: &'a mut Vec<u8>,
) -> ReadToEndFuture<'a, Self>where
Self: Unpin,
fn read_to_end<'a>(
&'a mut self,
buf: &'a mut Vec<u8>,
) -> ReadToEndFuture<'a, Self>where
Self: Unpin,
Source§fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String,
) -> ReadToStringFuture<'a, Self>where
Self: Unpin,
fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String,
) -> ReadToStringFuture<'a, Self>where
Self: Unpin,
Source§fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self>where
Self: Unpin,
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self>where
Self: Unpin,
Reads the exact number of bytes required to fill
buf
. Read moreSource§fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
Creates an adapter which will read at most
limit
bytes from it. Read moreSource§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more