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
impl CoroutineContext
Sourcepub fn read_exact_at<'a>(
&'a mut self,
offset: u64,
out: &'a mut [u8],
) -> impl Future<Output = Result<(), CoroutineError>> + 'a
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.
Sourcepub fn read_many_at<'a, 'b: 'a>(
&'a mut self,
reqs: &'a mut [(u64, &'b mut [u8])],
) -> impl Future<Output = Result<(), CoroutineError>> + 'a
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.
Sourcepub async fn read_exact(&mut self, out: &mut [u8]) -> Result<(), CoroutineError>
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.
Sourcepub fn cursor(&self) -> u64
pub fn cursor(&self) -> u64
The sequential cursor used by read_exact.
Sourcepub fn len(&mut self) -> impl Future<Output = Result<u64, CoroutineError>> + '_
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.
Sourcepub fn write_rows<'a>(
&'a mut self,
meta: BatchMeta,
rows: &PixelSlice<'_>,
) -> impl Future<Output = Result<(), CoroutineError>> + 'a
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.
Sourcepub fn announce(
&mut self,
update: MetadataUpdate,
) -> impl Future<Output = Result<(), CoroutineError>> + '_
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.
Sourcepub fn set_info(&mut self, info: ImageInfo)
pub fn set_info(&mut self, info: ImageInfo)
Set image metadata (visible through IncrementalDecode::info).
Sourcepub fn set_details(&mut self, details: DecodeDetails)
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.
Sourcepub fn set_output_descriptor(&mut self, descriptor: PixelDescriptor)
pub fn set_output_descriptor(&mut self, descriptor: PixelDescriptor)
Set the negotiated output descriptor.
Sourcepub fn interpretation(
&mut self,
facts: InterpretationFacts,
) -> impl Future<Output = Result<BoundaryAction, CoroutineError>> + '_
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.
Sourcepub fn accepts_provisional(&self) -> bool
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.
Sourcepub fn check_stop(&self) -> Result<(), CoroutineError>
pub fn check_stop(&self) -> Result<(), CoroutineError>
Check the driver’s stop token without suspending.