Skip to main content

CoroutineDecoder

Struct CoroutineDecoder 

Source
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,

Source

pub fn new(init: impl FnOnce(CoroutineContext) -> F) -> Self

Create a decoder with the default input cap and AccessPattern::RandomAccess.

Source

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.

Source

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.

Source

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.

Source

pub fn retained_input(&self) -> usize

Unread input currently retained, in bytes.

Source§

impl<E> CoroutineDecoder<BoxFuture<E>, E>
where E: Error + Send + Sync + From<CoroutineError> + 'static,

Source

pub fn boxed<Fut>(init: impl FnOnce(CoroutineContext) -> Fut) -> Self
where Fut: Future<Output = Result<OutputInfo, E>> + Send + 'static,

Like new, boxing the future so the decoder type is BoxedCoroutineDecoder regardless of the async block.

Source

pub fn boxed_with_options<Fut>( input_cap: usize, access: AccessPattern, init: impl FnOnce(CoroutineContext) -> Fut, ) -> Self
where Fut: Future<Output = Result<OutputInfo, E>> + Send + 'static,

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,

Source§

fn step_controlled( &mut self, input: Input<'_>, sink: &mut dyn DecodeRowSink, pulse: Option<&dyn Pulse>, ) -> Result<ControlledProgress, StepError<E>>

Advance or return a mandatory suspension. 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>>

Resume exactly one outstanding boundary. A stale, invalid or cancelled reply is terminal. This performs no sink work. 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,

Source§

type Error = E

The codec-specific error type.
Source§

fn step( &mut self, input: Input<'_>, sink: &mut dyn DecodeRowSink, pulse: Option<&dyn Pulse>, ) -> Result<Progress, StepError<E>>

Take bytes from the front of input and advance by one event. Read more
Source§

fn requested(&self) -> &[InputRequest]

What the decoder needs, valid after a step returned Event::Need (never empty then). Empty otherwise.
Source§

fn info(&self) -> Option<&ImageInfo>

Image metadata, once the header has been parsed.
Source§

fn take_details(&mut self) -> Option<DecodeDetails>

Take the owned details of a successfully completed decode, at most once. Read more
Source§

fn output_descriptor(&self) -> Option<PixelDescriptor>

Output pixel descriptor, once the header has been parsed.
Source§

fn access_pattern(&self) -> AccessPattern

How this decoder reads its input, so a driver can choose a buffering strategy. May change once the format is known.

Auto Trait Implementations§

§

impl<F, E> !RefUnwindSafe for CoroutineDecoder<F, E>

§

impl<F, E> !UnwindSafe for CoroutineDecoder<F, E>

§

impl<F, E> Freeze for CoroutineDecoder<F, E>

§

impl<F, E> Send for CoroutineDecoder<F, E>
where F: Send,

§

impl<F, E> Sync for CoroutineDecoder<F, E>
where F: Sync,

§

impl<F, E> Unpin for CoroutineDecoder<F, E>

§

impl<F, E> UnsafeUnpin for CoroutineDecoder<F, E>

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.