Skip to main content

AsyncTranscodeDecodeInput

Struct AsyncTranscodeDecodeInput 

Source
pub struct AsyncTranscodeDecodeInput<I>
where I: AsyncInput, I::Item: Copy + Default,
{ /* private fields */ }
Expand description

Decodes an asynchronous unit stream into values.

The adapter owns unit buffering but not decoder state. Callers supply a streaming decoder and error mapper for each operation.

§Type Parameters

  • I: Wrapped asynchronous unit input.

Implementations§

Source§

impl<I> AsyncTranscodeDecodeInput<I>
where I: AsyncInput, I::Item: Copy + Default,

Source

pub fn new(inner: I) -> Self

Creates an adapter with the default unit-buffer capacity.

§Parameters
  • inner: Unit input read by this adapter.
§Returns

Returns a new buffered asynchronous decoder input.

Source

pub fn with_capacity(inner: I, capacity: usize) -> Self

Creates an adapter with an internal unit buffer of at least capacity.

§Parameters
  • inner: Unit input read by this adapter.
  • capacity: Requested internal unit-buffer capacity.
§Returns

Returns a new buffered asynchronous decoder input.

Source

pub fn try_with_capacity( inner: I, capacity: usize, ) -> Result<Self, TryReserveError>

Tries to create an adapter with an internal unit buffer of at least capacity.

§Errors

Returns the allocation error when the internal buffer cannot be allocated.

Source

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

Returns a shared reference to the wrapped asynchronous input.

The input can be physically positioned after units retained in this adapter’s unread buffer.

Source

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

Returns a mutable reference to the wrapped asynchronous input.

Direct reads can invalidate the logical stream position represented by unread buffered units.

Source

pub const fn unread_len(&self) -> usize

Returns the number of unread units currently buffered.

Source

pub fn unread(&self) -> &[I::Item]

Returns the unread buffered unit window.

Source

pub fn capacity(&self) -> usize

Returns the total internal unit-buffer capacity.

Source

pub fn consume(&mut self, count: usize)

Consumes unread units from the current buffer window.

§Panics

Panics when count exceeds the unread unit count.

Source

pub unsafe fn copy_unread_to( &self, output: &mut [I::Item], output_index: usize, count: usize, )

Copies unread units into an indexed output range without consuming them.

§Safety

The caller must guarantee that the indexed range fits in output, does not overflow, holds no overlapping unread units, and count is no greater than the unread unit count.

Source

pub fn into_parts(self) -> (I, Buffer<I::Item>)

Consumes this adapter and returns the input plus its unread buffer.

Source

pub fn reset<D, M, Value>( &self, decoder: &mut D, map_error: &mut M, output: &mut [Value], output_index: usize, count: usize, ) -> Result<usize>
where D: Transcoder<Input = I::Item, Output = Value>, M: FnMut(D::Error) -> Error,

Runs decoder reset into an indexed output range without I/O.

§Errors

Returns invalid output-range, capacity, or mapped decoder-reset errors.

§Panics

Panics if the decoder writes more values than its reset bound.

Source

pub fn finish<D, M, Value>( &self, decoder: &mut D, map_error: &mut M, output: &mut [Value], output_index: usize, count: usize, ) -> Result<usize>
where D: Transcoder<Input = I::Item, Output = Value>, M: FnMut(D::Error) -> Error,

Finishes a decoder into an indexed output range without I/O.

§Errors

Returns invalid output-range, capacity, or mapped decoder-finish errors.

§Panics

Panics if the decoder writes more values than its finish bound.

Source§

impl<I> AsyncTranscodeDecodeInput<I>
where I: AsyncInput + Unpin, I::Item: Copy + Default + Unpin,

Source

pub async fn fill_more_async(&mut self) -> Result<bool>

Appends at least one unit to the unread buffer.

§Returns

Returns true when data was appended, or false at end of input.

§Errors

Returns input or buffer-management errors while refilling.

Source

pub async fn fill_until_async(&mut self, count: usize) -> Result<bool>

Refills until at least count unread units are available.

§Returns

Returns true when count units are available, or false when EOF occurs first.

§Errors

Returns allocation, input, or buffer-management errors while refilling.

Source

pub fn poll_transcode<D, M, Value>( self: Pin<&mut Self>, cx: &mut Context<'_>, decoder: &mut D, map_error: &mut M, output: &mut [Value], output_index: usize, count: usize, ) -> Poll<Result<AsyncTranscodeDecodeStep>>
where D: Transcoder<Input = I::Item, Output = Value>, M: FnMut(D::Error) -> Error,

Polls one cancellation-safe decoder operation.

The operation first refills only when no unread unit is buffered. After a decoder call changes either the decoder or the buffered input, it immediately returns AsyncTranscodeDecodeStep::Progress and never polls the input again. This makes the returned progress the commit boundary for cancellation: resume with the adapter’s current state, rather than replaying the previous source range.

§Errors

Returns input, allocation, output-range, invalid-progress, or mapped decoder errors.

Source

pub async fn transcode_async<D, M, Value>( &mut self, decoder: &mut D, map_error: &mut M, output: &mut [Value], output_index: usize, count: usize, ) -> Result<AsyncTranscodeDecodeStep>
where D: Transcoder<Input = I::Item, Output = Value>, M: FnMut(D::Error) -> Error,

Decodes one cancellation-safe progress step into an indexed output range.

This is the async wrapper for Self::poll_transcode. It returns after one decoder invocation; callers that require a complete destination range must drive successive steps and retain each returned progress.

Trait Implementations§

Source§

impl<I> AsyncInput for AsyncTranscodeDecodeInput<I>
where I: AsyncInput, I::Item: Copy + Default,

Source§

type Item = <I as AsyncInput>::Item

Item type read through the retained unit buffer.

Source§

fn is_buffered(&self) -> bool

Reports that this input retains unread units.

Source§

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

Polls one read through the retained unit buffer.

§Safety

The caller must provide a valid indexed output range.

Source§

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

Polls a read into the full destination slice. Read more
Source§

fn read_async<'a>( &'a mut self, output: &'a mut [Self::Item], ) -> ReadFuture<'a, Self>
where Self: Sized + Unpin,

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

fn read_fully_async<'a>( &'a mut self, output: &'a mut [Self::Item], ) -> ReadFullyFuture<'a, Self>
where Self: Sized + Unpin,

Creates a future that fills a destination as far as possible. Read more
Source§

fn read_exactly_async<'a>( &'a mut self, output: &'a mut [Self::Item], ) -> ReadExactFuture<'a, Self>
where Self: Sized + Unpin,

Creates a future that fills the entire destination. Read more
Source§

impl<I> Debug for AsyncTranscodeDecodeInput<I>

Source§

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

Formats this asynchronous decoder input for debugging.

Auto Trait Implementations§

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 = Infallible

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

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

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.