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]

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<'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> 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> UnwindSafe for MappedReader<R, F> where
    F: UnwindSafe,
    R: UnwindSafe

Blanket Implementations

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

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

impl<R> AsyncReadUtil for R where
    R: AsyncRead, 
[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.