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§
Sourcetype State: Clone + Serialize + DeserializeOwned
type State: Clone + Serialize + DeserializeOwned
Owned state, independent of future decoder progress.
Required Methods§
Sourcefn error_sequence(&self, error: &Self::Error) -> SequenceId
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.
Sourcefn validate_snapshot(&self, state: &Self::State) -> Result<(), Self::Error>
fn validate_snapshot(&self, state: &Self::State) -> Result<(), Self::Error>
Validates without changing the source.
Sourcefn restore_validated(&mut self, state: &Self::State)
fn restore_validated(&mut self, state: &Self::State)
Applies state previously accepted by validation.
Provided Methods§
Sourcefn set_run_context(&mut self, _context: WorkerContext)
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".