Skip to main content

AsyncChecksumOutput

Struct AsyncChecksumOutput 

Source
pub struct AsyncChecksumOutput<O, H> { /* private fields */ }
Expand description

Asynchronous byte output that hashes successfully accepted bytes.

Pending and failed writes do not change the hasher. The checksum algorithm and stability guarantees are those of the supplied Hasher.

§Type Parameters

  • O: Wrapped asynchronous byte output type.
  • H: Checksum hasher type.

Implementations§

Source§

impl<O, H> AsyncChecksumOutput<O, H>
where H: Hasher,

Source

pub const fn new(inner: O, hasher: H) -> Self

Creates a checksum-tracking asynchronous output.

§Parameters
  • inner: Asynchronous byte output to wrap.
  • hasher: Hasher updated after successful writes.
§Returns

Returns an output with the supplied initial hasher state.

Source

pub fn checksum(&self) -> u64

Returns the current checksum value.

§Returns

Returns Hasher::finish for the current state.

Source

pub const fn inner(&self) -> &O

Returns a shared reference to the wrapped output.

§Returns

Returns the wrapped asynchronous byte output.

Source

pub fn inner_mut(&mut self) -> &mut O

Returns a mutable reference to the wrapped output.

Writes performed directly on the returned output do not update this wrapper’s hasher.

§Returns

Returns the wrapped asynchronous byte output.

Source

pub const fn hasher(&self) -> &H

Returns a shared reference to the hasher.

§Returns

Returns the current hasher state.

Source

pub fn hasher_mut(&mut self) -> &mut H

Returns a mutable reference to the hasher.

Mutating the returned hasher changes the checksum independently of bytes written through this wrapper.

§Returns

Returns the current hasher state mutably.

Source

pub fn into_parts(self) -> (O, H)

Consumes this wrapper without flushing the wrapped output.

This method does not call AsyncOutput::flush_async and performs no asynchronous I/O. Any buffering owned by the returned output remains pending and unchanged.

§Returns

Returns the wrapped output and final hasher state.

Trait Implementations§

Source§

impl<O, H> AsyncClose for AsyncChecksumOutput<O, H>
where O: AsyncClose<Item = u8>, H: Hasher,

Source§

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

Polls closing through the wrapped output.

§Parameters
  • cx: Task context used to register a wake-up.
§Returns

Returns Poll::Pending while closing is incomplete, otherwise a ready success result.

§Errors

Returns an error reported by the wrapped output. Invalid asynchronous error kinds are normalized to io::ErrorKind::InvalidData.

Source§

fn close_async(&mut self) -> CloseFuture<'_, Self> ⓘ
where Self: Sized + Unpin,

Creates a future that closes this output. Read more
Source§

impl<O, H> AsyncOutput for AsyncChecksumOutput<O, H>
where O: AsyncOutput<Item = u8>, H: Hasher,

Source§

type Item = u8

Byte item hashed after successful writes.

Source§

fn is_buffered(&self) -> bool

Preserves the wrapped output’s buffering declaration.

§Returns

Returns the wrapped output’s buffering declaration.

Source§

unsafe fn poll_write_unchecked( self: Pin<&mut Self>, cx: &mut Context<'_>, input: &[u8], index: usize, count: usize, ) -> Poll<Result<usize>>

Polls a write and hashes only bytes in a successful ready result.

§Parameters
  • cx: Task context used to register a wake-up.
  • input: Source byte slice.
  • index: Starting source index.
  • count: Maximum number of bytes to write.
§Returns

Returns Poll::Pending when the output is not ready. A ready success contains the number of bytes accepted and hashed.

§Errors

Returns an I/O error reported by the wrapped output without changing the hasher.

§Safety

The range index..index + count must be valid for input.

Source§

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

Polls the wrapped output’s flush operation.

§Parameters
  • cx: Task context used to register a wake-up.
§Returns

Returns Poll::Pending while flushing is incomplete, otherwise a ready success result.

§Errors

Returns an error reported by the wrapped output. Invalid asynchronous error kinds are normalized to io::ErrorKind::InvalidData.

Source§

fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, input: &[Self::Item], ) -> Poll<Result<usize>>

Polls one write from the full source slice. Read more
Source§

fn write_async<'a>( &'a mut self, input: &'a [Self::Item], ) -> WriteFuture<'a, Self> ⓘ
where Self: Sized + Unpin,

Creates a future that performs one asynchronous write operation. Read more
Source§

fn write_fully_async<'a>( &'a mut self, input: &'a [Self::Item], ) -> WriteFullyFuture<'a, Self> ⓘ
where Self: Sized + Unpin,

Creates a future that writes the entire source slice. Read more
Source§

fn flush_async(&mut self) -> FlushFuture<'_, Self> ⓘ
where Self: Sized + Unpin,

Creates a future that flushes internally buffered items. Read more
Source§

impl<O: Debug, H: Debug> Debug for AsyncChecksumOutput<O, H>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<O, H> Freeze for AsyncChecksumOutput<O, H>
where O: Freeze, H: Freeze,

§

impl<O, H> RefUnwindSafe for AsyncChecksumOutput<O, H>

§

impl<O, H> Send for AsyncChecksumOutput<O, H>
where O: Send, H: Send,

§

impl<O, H> Sync for AsyncChecksumOutput<O, H>
where O: Sync, H: Sync,

§

impl<O, H> Unpin for AsyncChecksumOutput<O, H>
where O: Unpin, H: Unpin,

§

impl<O, H> UnsafeUnpin for AsyncChecksumOutput<O, H>
where O: UnsafeUnpin, H: UnsafeUnpin,

§

impl<O, H> UnwindSafe for AsyncChecksumOutput<O, H>
where O: UnwindSafe, H: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.