pub struct StreamAttempt<'outcome> { /* private fields */ }Expand description
SDK-owned accounting attempt over caller-owned outcome state.
Only one source chunk may be outstanding. Dropping an active attempt marks it cancelled and records whether a sink write was never attempted, needs transactional rollback, or may already be externally visible.
Implementations§
Source§impl<'outcome> StreamAttempt<'outcome>
impl<'outcome> StreamAttempt<'outcome>
Sourcepub fn new(policy: StreamPolicy, outcome: &'outcome mut StreamOutcome) -> Self
pub fn new(policy: StreamPolicy, outcome: &'outcome mut StreamOutcome) -> Self
Starts one attempt and marks the supplied outcome slot active.
Sourcepub const fn progress(&self) -> StreamProgress
pub const fn progress(&self) -> StreamProgress
Returns current counters.
Sourcepub fn begin_source_observation(&mut self) -> Result<(), StreamProgressError>
pub fn begin_source_observation(&mut self) -> Result<(), StreamProgressError>
Reserves one source observation before external source code is called.
The returned source result must be classified with Self::begin_chunk,
Self::observe_wait, or Self::finish.
Sourcepub fn begin_chunk(&mut self, len: usize) -> Result<(), StreamProgressError>
pub fn begin_chunk(&mut self, len: usize) -> Result<(), StreamProgressError>
Classifies a preflight source observation as one complete chunk.
The next chunk is rejected until Self::advance accepts every pending
byte, which makes backpressure deterministic.
Sourcepub fn begin_sink_observation(&mut self) -> Result<(), StreamProgressError>
pub fn begin_sink_observation(&mut self) -> Result<(), StreamProgressError>
Reserves one sink observation and conservatively records a write attempt before external sink code is called.
Sourcepub fn advance(&mut self, accepted: usize) -> Result<(), StreamProgressError>
pub fn advance(&mut self, accepted: usize) -> Result<(), StreamProgressError>
Classifies a preflight sink observation with actual accepted bytes.
Sourcepub fn observe_wait(&mut self) -> Result<(), StreamProgressError>
pub fn observe_wait(&mut self) -> Result<(), StreamProgressError>
Classifies a preflight source observation that produced no chunk.
Sourcepub fn mark_failed(&mut self)
pub fn mark_failed(&mut self)
Marks an external source or sink error so drop records failure, not cancellation.
Sourcepub fn finish(&mut self) -> Result<StreamCompletion, StreamProgressError>
pub fn finish(&mut self) -> Result<StreamCompletion, StreamProgressError>
Classifies a preflight source observation as end and validates length.
Sourcepub fn commit_sink(&mut self) -> Result<(), StreamProgressError>
pub fn commit_sink(&mut self) -> Result<(), StreamProgressError>
Records successful sink commitment after Self::finish validated end.