Skip to main content

CoroutineContext

Struct CoroutineContext 

Source
pub struct CoroutineContext { /* private fields */ }
Expand description

Handle a coroutine decode uses to read input and emit output.

Every async fn here suspends the coroutine when it cannot proceed and resumes it on the step after the driver supplied what was missing.

Implementations§

Source§

impl CoroutineContext

Source

pub fn read_exact_at<'a>( &'a mut self, offset: u64, out: &'a mut [u8], ) -> impl Future<Output = Result<(), CoroutineError>> + 'a

Read exactly out.len() bytes at offset.

Suspends with Event::Need (a InputRequest::Range) until the driver offers the span. Fails with SourceError::UnexpectedEof once the announced length shows the span can never arrive.

Source

pub fn read_many_at<'a, 'b: 'a>( &'a mut self, reqs: &'a mut [(u64, &'b mut [u8])], ) -> impl Future<Output = Result<(), CoroutineError>> + 'a

Read several spans at once. The driver sees one Event::Need naming every missing span, so a batching source fetches them in one round.

Source

pub async fn read_exact(&mut self, out: &mut [u8]) -> Result<(), CoroutineError>

Read the next out.len() bytes at the sequential cursor and advance it. Suspends with one InputRequest::AtLeast for the rest of the read, which stream pumps serve by reading forward. Bytes behind the cursor are released.

Source

pub fn cursor(&self) -> u64

The sequential cursor used by read_exact.

Source

pub fn seek(&mut self, offset: u64)

Move the sequential cursor (bytes behind it are released).

Source

pub fn len(&mut self) -> impl Future<Output = Result<u64, CoroutineError>> + '_

Total source length. Suspends with InputRequest::Len until a driver offers an input carrying it.

Source

pub fn write_rows<'a>( &'a mut self, meta: BatchMeta, rows: &PixelSlice<'_>, ) -> impl Future<Output = Result<(), CoroutineError>> + 'a

Hand a strip of rows to the driver. Suspends until the decoder has copied it into the sink. Each Event::Rows delivers at most one buffer allowed by the sink’s max_buffer_rows; a larger batch stays retained across steps until every row is delivered. This bounds queued sink buffers, not the native batch’s storage.

Provisional rows (!meta.is_final) may be written only when accepts_provisional is true.

Source

pub fn announce( &mut self, update: MetadataUpdate, ) -> impl Future<Output = Result<(), CoroutineError>> + '_

Report a metadata event to the driver (one Event::Metadata). HeaderReady with dimensions and descriptor set lets the decoder call sink.begin early.

Source

pub fn set_info(&mut self, info: ImageInfo)

Set image metadata (visible through IncrementalDecode::info).

Source

pub fn set_details(&mut self, details: DecodeDetails)

Supply the owned result details for terminal extraction.

These remain private until the future and sink finish successfully. Replacing a pending value drops its old owners. Failure or cancellation discards pending details; take_details never returns a partial result. This is not a metadata-completeness or privacy certificate. The producer must include every result detail promised by its configured operation.

Source

pub fn set_output_descriptor(&mut self, descriptor: PixelDescriptor)

Set the negotiated output descriptor.

Source

pub fn interpretation( &mut self, facts: InterpretationFacts, ) -> impl Future<Output = Result<BoundaryAction, CoroutineError>> + '_

Suspend before work affected by these interpretation facts. Await this before conversion or output. ContinueReading permits discovery only; rows stay blocked until final interpretation is adopted. This future is served only by the controlled protocol; legacy execution refuses it.

Source

pub fn accepts_provisional(&self) -> bool

Whether the driver’s sink takes provisional (progressive) rows. Known once the header has been announced (the decoder reads it when it calls the sink’s begin); false before that.

Source

pub fn check_stop(&self) -> Result<(), CoroutineError>

Check the driver’s stop token without suspending.

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.