Struct InspectWriter

pub struct InspectWriter<W, F> { /* private fields */ }

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

This is useful for things like hashing data as it's written out.

Implementations

impl<W, F> InspectWriter<W, F>

fn new(writer: W, f: F) -> InspectWriter<W, F>
where
    W: AsyncWrite,
    F: FnMut(&[u8]),

Create a new InspectWriter, wrapping write and calling f for the data successfully written by each write call.

The closure f will never be called with an empty slice. A vectored write can result in multiple calls to f - at most one call to f per buffer supplied to poll_write_vectored.

fn into_inner(self) -> W

Consumes the InspectWriter, returning the wrapped writer

Trait Implementations

impl<'__pin, W, F> Unpin for InspectWriter<W, F> where PinnedFieldsOf<__Origin<'__pin, W, F>>: Unpin,

impl<W: AsyncRead, F> AsyncRead for InspectWriter<W, F>

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

impl<W: AsyncWrite, F: FnMut(&[u8])> AsyncWrite for InspectWriter<W, F>

fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize>>
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
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<W, F> Freeze for InspectWriter<W, F> where W: Freeze, F: Freeze,

impl<W, F> RefUnwindSafe for InspectWriter<W, F> where W: RefUnwindSafe, F: RefUnwindSafe,

impl<W, F> Send for InspectWriter<W, F> where W: Send, F: Send,

impl<W, F> Sync for InspectWriter<W, F> where W: Sync, F: Sync,

impl<W, F> UnsafeUnpin for InspectWriter<W, F> where W: UnsafeUnpin, F: UnsafeUnpin,

impl<W, F> UnwindSafe for InspectWriter<W, F> where W: UnwindSafe, F: UnwindSafe,

Blanket Implementations

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

impl<T> Any for InspectWriter<W, F> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for InspectWriter<W, F> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for InspectWriter<W, F> where T: ?Sized,

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

impl<T> From<T> for InspectWriter<W, F>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into<U> for InspectWriter<W, 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 InspectWriter<W, 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 InspectWriter<W, 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 InspectWriter<W, F> where W: AsyncWrite + ?Sized,