Skip to main content

AsyncCountingOutput

Struct AsyncCountingOutput 

Source
pub struct AsyncCountingOutput<O> { /* private fields */ }
Expand description

Asynchronous output that counts successfully accepted items.

§Type Parameters

  • O: Wrapped asynchronous output type.

Implementations§

Source§

impl<O> AsyncCountingOutput<O>

Source

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

Creates a counting asynchronous output.

§Parameters
  • inner: Asynchronous output to wrap.
§Returns

Returns an output whose item count starts at zero.

Source

pub const fn items_written(&self) -> u64

Returns the successfully accepted item count.

§Returns

Returns a count that saturates at u64::MAX.

Source

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

Returns a shared reference to the wrapped output.

§Returns

Returns the wrapped asynchronous 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 are not included in this wrapper’s item count.

§Returns

Returns the wrapped asynchronous output.

Source

pub fn into_inner(self) -> O

Consumes this wrapper and returns the wrapped output.

§Returns

Returns the asynchronous output.

Source§

impl<O> AsyncCountingOutput<O>
where O: AsyncOutput<Item = u8>,

Source

pub const fn bytes_written(&self) -> u64

Returns the successfully accepted byte count.

§Returns

Returns the same value as Self::items_written.

Trait Implementations§

Source§

impl<O> AsyncClose for AsyncCountingOutput<O>
where O: AsyncClose,

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> AsyncOutput for AsyncCountingOutput<O>
where O: AsyncOutput,

Source§

type Item = <O as AsyncOutput>::Item

Item type counted 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: &[Self::Item], index: usize, count: usize, ) -> Poll<Result<usize>>

Polls a write and counts only a successful ready result.

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

Returns Poll::Pending when the output is not ready. A ready success contains the number of items accepted and added to the saturating count.

§Errors

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

§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> Debug for AsyncCountingOutput<O>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<O> Freeze for AsyncCountingOutput<O>
where O: Freeze,

§

impl<O> RefUnwindSafe for AsyncCountingOutput<O>
where O: RefUnwindSafe,

§

impl<O> Send for AsyncCountingOutput<O>
where O: Send,

§

impl<O> Sync for AsyncCountingOutput<O>
where O: Sync,

§

impl<O> Unpin for AsyncCountingOutput<O>
where O: Unpin,

§

impl<O> UnsafeUnpin for AsyncCountingOutput<O>
where O: UnsafeUnpin,

§

impl<O> UnwindSafe for AsyncCountingOutput<O>
where O: 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.