Skip to main content

CheckpointableSource

Trait CheckpointableSource 

Source
pub trait CheckpointableSource: Iterator<Item = Result<WorkerRecord<Self::Sample>, Self::Error>> {
    type Sample;
    type State: Clone + Serialize + DeserializeOwned;
    type Error;

    // Required methods
    fn error_sequence(&self, error: &Self::Error) -> SequenceId;
    fn snapshot(&self) -> Self::State;
    fn validate_snapshot(&self, state: &Self::State) -> Result<(), Self::Error>;
    fn restore_validated(&mut self, state: &Self::State);

    // Provided method
    fn set_run_context(&mut self, _context: WorkerContext) { ... }
}
Expand description

Replay-safe source with self-contained state captured before each read.

Validation is read-only; applying accepted state must not fail or panic. Records must have strictly increasing per-shard global sequence IDs.

Required Associated Types§

Source

type Sample

Owned decoded sample.

Source

type State: Clone + Serialize + DeserializeOwned

Owned state, independent of future decoder progress.

Source

type Error

Preserved source error.

Required Methods§

Source

fn error_sequence(&self, error: &Self::Error) -> SequenceId

Returns the failed read’s stable global position without changing state.

Called after next() returns an error. This position must obey the shard’s strictly increasing sequence contract and repeat after rollback.

Source

fn snapshot(&self) -> Self::State

Captures the boundary before the next read attempt.

Source

fn validate_snapshot(&self, state: &Self::State) -> Result<(), Self::Error>

Validates without changing the source.

Source

fn restore_validated(&mut self, state: &Self::State)

Applies state previously accepted by validation.

Provided Methods§

Source

fn set_run_context(&mut self, _context: WorkerContext)

Replaces the run cancellation/deadline context before resumed reads.

Sources retaining a context must override this method and replace it. Logical worker generation and seed remain unchanged. This must not fail.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§