Struct async_read_util::MappedReader [−][src]
pub struct MappedReader<R, F> { /* fields omitted */ }
An async reader which allows a closure to map the output of the inner async reader into a new buffer. This allows things like compression/encryption to be layered on top of a normal reader.
NOTE: The closure must consume at least 1 byte for the reader to continue.
SAFETY: This currently creates the equivalent of Box<[MaybeUninit<u8>]>
,
but does so through use of accessing the allocator directly. Once new_uninit
is available on stable, Box::new_uninit_slice
will be used. This will
still utilize unsafe. A uninitialized buffer is acceptable because it’s
contents are only ever written to before reading only the written section.
ref: https://github.com/rust-lang/rust/issues/63291
Implementations
impl<R, F> MappedReader<R, F> where
R: AsyncRead,
F: FnMut(&[u8], &mut [u8]) -> (usize, usize),
[src]
impl<R, F> MappedReader<R, F> where
R: AsyncRead,
F: FnMut(&[u8], &mut [u8]) -> (usize, usize),
[src]pub fn new(inner: R, f: F) -> Self
[src]
pub fn with_capacity(capacity: usize, inner: R, f: F) -> Self
[src]
Trait Implementations
impl<R, F> AsyncRead for MappedReader<R, F> where
R: AsyncRead,
F: FnMut(&[u8], &mut [u8]) -> (usize, usize),
[src]
impl<R, F> AsyncRead for MappedReader<R, F> where
R: AsyncRead,
F: FnMut(&[u8], &mut [u8]) -> (usize, usize),
[src]impl<'pin, R, F> Unpin for MappedReader<R, F> where
__MappedReader<'pin, R, F>: Unpin,
[src]
impl<'pin, R, F> Unpin for MappedReader<R, F> where
__MappedReader<'pin, R, F>: Unpin,
[src]Auto Trait Implementations
impl<R, F> RefUnwindSafe for MappedReader<R, F> where
F: RefUnwindSafe,
R: RefUnwindSafe,
impl<R, F> RefUnwindSafe for MappedReader<R, F> where
F: RefUnwindSafe,
R: RefUnwindSafe,
impl<R, F> Send for MappedReader<R, F> where
F: Send,
R: Send,
impl<R, F> Send for MappedReader<R, F> where
F: Send,
R: Send,
impl<R, F> Sync for MappedReader<R, F> where
F: Sync,
R: Sync,
impl<R, F> Sync for MappedReader<R, F> where
F: Sync,
R: Sync,
impl<R, F> UnwindSafe for MappedReader<R, F> where
F: UnwindSafe,
R: UnwindSafe,
impl<R, F> UnwindSafe for MappedReader<R, F> where
F: UnwindSafe,
R: UnwindSafe,
Blanket Implementations
impl<R> AsyncReadExt for R where
R: AsyncRead + ?Sized,
impl<R> AsyncReadExt for R where
R: AsyncRead + ?Sized,
pub fn chain<R>(self, next: R) -> Chain<Self, R> where
R: AsyncRead,
R: AsyncRead,
pub fn read(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self> where
Self: Unpin,
Self: Unpin,
pub fn read_vectored(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectored<'a, Self> where
Self: Unpin,
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectored<'a, Self> where
Self: Unpin,
pub fn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self> where
Self: Unpin,
Self: Unpin,
pub fn read_to_end(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEnd<'a, Self> where
Self: Unpin,
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEnd<'a, Self> where
Self: Unpin,
pub fn read_to_string(
&'a mut self,
buf: &'a mut String
) -> ReadToString<'a, Self> where
Self: Unpin,
&'a mut self,
buf: &'a mut String
) -> ReadToString<'a, Self> where
Self: Unpin,
pub fn split(self) -> (ReadHalf<Self>, WriteHalf<Self>) where
Self: AsyncWrite,
Self: AsyncWrite,
pub fn take(self, limit: u64) -> Take<Self>
impl<R> AsyncReadUtil for R where
R: AsyncRead,
[src]
impl<R> AsyncReadUtil for R where
R: AsyncRead,
[src]