pub struct CoroutineDecoder<F, E> { /* private fields */ }Expand description
An IncrementalDecode whose logic is an async block.
Build one with new from a closure that receives the
CoroutineContext and returns the decode future. The future’s error
type is the codec’s; it must be constructible from CoroutineError
so the context’s ? operator works.
Implementations§
Source§impl<F, E> CoroutineDecoder<F, E>where
F: Future<Output = Result<OutputInfo, E>> + Send + 'static,
E: Error + Send + Sync + From<CoroutineError> + 'static,
impl<F, E> CoroutineDecoder<F, E>where
F: Future<Output = Result<OutputInfo, E>> + Send + 'static,
E: Error + Send + Sync + From<CoroutineError> + 'static,
Sourcepub fn new(init: impl FnOnce(CoroutineContext) -> F) -> Self
pub fn new(init: impl FnOnce(CoroutineContext) -> F) -> Self
Create a decoder with the default input cap and
AccessPattern::RandomAccess.
Sourcepub fn controlled(
input_cap: usize,
access: AccessPattern,
init: impl FnOnce(CoroutineContext) -> F,
) -> Self
pub fn controlled( input_cap: usize, access: AccessPattern, init: impl FnOnce(CoroutineContext) -> F, ) -> Self
Create a decoder requiring explicit interpretation decisions. No sink
effects are allowed until ctx.interpretation(...).await has received
adoption of final facts. Serve this through step_controlled; legacy
step refuses before polling the future.
Sourcepub fn controlled_with_storage(
input_cap: usize,
access: AccessPattern,
storage: StorageBudget,
init: impl FnOnce(CoroutineContext) -> F,
) -> Result<Self, CoroutineError>
pub fn controlled_with_storage( input_cap: usize, access: AccessPattern, storage: StorageBudget, init: impl FnOnce(CoroutineContext) -> F, ) -> Result<Self, CoroutineError>
Controlled decoding with admitted input payload, range index and row
staging. Admission runs before init is called. The input index holds at
most 64 disjoint spans; excess fragmentation is an error, never eviction.
Native workspace, image metadata, request bookkeeping and sink allocations
are outside this scoped allowance. Reuse the same budget in native code
to admit its additional owned buffers.
Sourcepub fn with_options(
input_cap: usize,
access: AccessPattern,
init: impl FnOnce(CoroutineContext) -> F,
) -> Self
pub fn with_options( input_cap: usize, access: AccessPattern, init: impl FnOnce(CoroutineContext) -> F, ) -> Self
Create a decoder that keeps at most input_cap unread bytes and
declares access to drivers.
Sourcepub fn retained_input(&self) -> usize
pub fn retained_input(&self) -> usize
Unread input currently retained, in bytes.
Source§impl<E> CoroutineDecoder<BoxFuture<E>, E>
impl<E> CoroutineDecoder<BoxFuture<E>, E>
Sourcepub fn boxed<Fut>(init: impl FnOnce(CoroutineContext) -> Fut) -> Self
pub fn boxed<Fut>(init: impl FnOnce(CoroutineContext) -> Fut) -> Self
Like new, boxing the future so the decoder type is
BoxedCoroutineDecoder regardless of the async block.
Sourcepub fn boxed_with_options<Fut>(
input_cap: usize,
access: AccessPattern,
init: impl FnOnce(CoroutineContext) -> Fut,
) -> Self
pub fn boxed_with_options<Fut>( input_cap: usize, access: AccessPattern, init: impl FnOnce(CoroutineContext) -> Fut, ) -> Self
Like with_options, boxing the future.
Trait Implementations§
Source§impl<F, E> ControlledIncrementalDecode for CoroutineDecoder<F, E>where
F: Future<Output = Result<OutputInfo, E>> + Send + 'static,
E: Error + Send + Sync + From<CoroutineError> + 'static,
impl<F, E> ControlledIncrementalDecode for CoroutineDecoder<F, E>where
F: Future<Output = Result<OutputInfo, E>> + Send + 'static,
E: Error + Send + Sync + From<CoroutineError> + 'static,
Source§fn step_controlled(
&mut self,
input: Input<'_>,
sink: &mut dyn DecodeRowSink,
pulse: Option<&dyn Pulse>,
) -> Result<ControlledProgress, StepError<E>>
fn step_controlled( &mut self, input: Input<'_>, sink: &mut dyn DecodeRowSink, pulse: Option<&dyn Pulse>, ) -> Result<ControlledProgress, StepError<E>>
None adds no per-call control; retained job controls still apply.Source§fn resume(
&mut self,
id: BoundaryId,
action: BoundaryAction,
pulse: Option<&dyn Pulse>,
) -> Result<(), StepError<E>>
fn resume( &mut self, id: BoundaryId, action: BoundaryAction, pulse: Option<&dyn Pulse>, ) -> Result<(), StepError<E>>
None preserves the
retained control and does not bypass cancellation at the boundary.Source§impl<F, E> IncrementalDecode for CoroutineDecoder<F, E>where
F: Future<Output = Result<OutputInfo, E>> + Send + 'static,
E: Error + Send + Sync + From<CoroutineError> + 'static,
impl<F, E> IncrementalDecode for CoroutineDecoder<F, E>where
F: Future<Output = Result<OutputInfo, E>> + Send + 'static,
E: Error + Send + Sync + From<CoroutineError> + 'static,
Source§fn step(
&mut self,
input: Input<'_>,
sink: &mut dyn DecodeRowSink,
pulse: Option<&dyn Pulse>,
) -> Result<Progress, StepError<E>>
fn step( &mut self, input: Input<'_>, sink: &mut dyn DecodeRowSink, pulse: Option<&dyn Pulse>, ) -> Result<Progress, StepError<E>>
input and advance by one event. Read moreSource§fn requested(&self) -> &[InputRequest]
fn requested(&self) -> &[InputRequest]
Event::Need
(never empty then). Empty otherwise.