Struct InspectReader

pub struct InspectReader<R, F> { /* private fields */ }

An adapter that lets you inspect the data that's being read.

This is useful for things like hashing data as it's read in.

Implementations

impl<R, F> InspectReader<R, F>

fn new(reader: R, f: F) -> InspectReader<R, F>
where
    R: AsyncRead,
    F: FnMut(&[u8]),

Create a new InspectReader, wrapping reader and calling f for the new data supplied by each read call.

The closure will only be called with an empty slice if the inner reader returns without reading data into the buffer. This happens at EOF, or if poll_read is called with a zero-size buffer.

fn into_inner(self) -> R

Consumes the InspectReader, returning the wrapped reader

Trait Implementations

impl<'__pin, R, F> Unpin for InspectReader<R, F> where PinnedFieldsOf<__Origin<'__pin, R, F>>: Unpin,

impl<R: AsyncRead, F: FnMut(&[u8])> AsyncRead for InspectReader<R, F>

fn poll_read(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>) -> Poll<Result<()>>

impl<R: AsyncWrite, F> AsyncWrite for InspectReader<R, F>

fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize, Error>>
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Error>>
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Error>>
fn poll_write_vectored(self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>]) -> Poll<Result<usize>>
fn is_write_vectored(&self) -> bool

Auto Trait Implementations

impl<R, F> Freeze for InspectReader<R, F> where R: Freeze, F: Freeze,

impl<R, F> RefUnwindSafe for InspectReader<R, F> where R: RefUnwindSafe, F: RefUnwindSafe,

impl<R, F> Send for InspectReader<R, F> where R: Send, F: Send,

impl<R, F> Sync for InspectReader<R, F> where R: Sync, F: Sync,

impl<R, F> UnsafeUnpin for InspectReader<R, F> where R: UnsafeUnpin, F: UnsafeUnpin,

impl<R, F> UnwindSafe for InspectReader<R, F> where R: UnwindSafe, F: UnwindSafe,

Blanket Implementations

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

impl<T> Any for InspectReader<R, F> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for InspectReader<R, F> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for InspectReader<R, F> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for InspectReader<R, F>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into<U> for InspectReader<R, F> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for InspectReader<R, F> where U: Into<T>,

type Error = Infallible;
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto<U> for InspectReader<R, F> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

impl<W> AsyncWriteExt for InspectReader<R, F> where W: AsyncWrite + ?Sized,