pub struct AsyncTranscodeDecodeInput<I>{ /* 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>
impl<I> AsyncTranscodeDecodeInput<I>
Sourcepub fn with_capacity(inner: I, capacity: usize) -> Self
pub fn with_capacity(inner: I, capacity: usize) -> Self
Sourcepub fn try_with_capacity(
inner: I,
capacity: usize,
) -> Result<Self, TryReserveError>
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.
Sourcepub const fn inner(&self) -> &I
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.
Sourcepub fn inner_mut(&mut self) -> &mut I
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.
Sourcepub const fn unread_len(&self) -> usize
pub const fn unread_len(&self) -> usize
Returns the number of unread units currently buffered.
Sourcepub fn consume(&mut self, count: usize)
pub fn consume(&mut self, count: usize)
Consumes unread units from the current buffer window.
§Panics
Panics when count exceeds the unread unit count.
Sourcepub unsafe fn copy_unread_to(
&self,
output: &mut [I::Item],
output_index: usize,
count: usize,
)
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.
Sourcepub fn into_parts(self) -> (I, Buffer<I::Item>)
pub fn into_parts(self) -> (I, Buffer<I::Item>)
Consumes this adapter and returns the input plus its unread buffer.
Sourcepub fn reset<D, M, Value>(
&self,
decoder: &mut D,
map_error: &mut M,
output: &mut [Value],
output_index: usize,
count: usize,
) -> Result<usize>
pub fn reset<D, M, Value>( &self, decoder: &mut D, map_error: &mut M, output: &mut [Value], output_index: usize, count: usize, ) -> Result<usize>
Source§impl<I> AsyncTranscodeDecodeInput<I>
impl<I> AsyncTranscodeDecodeInput<I>
Sourcepub async fn fill_more_async(&mut self) -> Result<bool>
pub async fn fill_more_async(&mut self) -> Result<bool>
Sourcepub async fn fill_until_async(&mut self, count: usize) -> Result<bool>
pub async fn fill_until_async(&mut self, count: usize) -> Result<bool>
Sourcepub 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>>
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>>
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.
Sourcepub 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>
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>
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>
impl<I> AsyncInput for AsyncTranscodeDecodeInput<I>
Source§type Item = <I as AsyncInput>::Item
type Item = <I as AsyncInput>::Item
Item type read through the retained unit buffer.
Source§fn is_buffered(&self) -> bool
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>>
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.