pub trait Checkpointable {
type State: Clone + Serialize + DeserializeOwned;
// Required methods
fn save_state(&self) -> Self::State;
fn validate_state(&self, state: &Self::State) -> Result<()>;
fn load_validated(&mut self, state: &Self::State);
}Expand description
A component whose state can be validated before it is restored.
Implement this on a custom collator or converter when it retains state that affects later batches. Built-in collators already supply it. Capture all relevant counters/configuration in an owned serde state; validation should reject incompatible values without resetting the live component.
Validation must be read-only. load_validated must not fail or panic after
the same component accepted the supplied state; violating either rule
breaks the resume transaction contract.
Required Associated Types§
Sourcetype State: Clone + Serialize + DeserializeOwned
type State: Clone + Serialize + DeserializeOwned
Owned serializable component state.
Required Methods§
Sourcefn save_state(&self) -> Self::State
fn save_state(&self) -> Self::State
Captures the current component state.
Sourcefn validate_state(&self, state: &Self::State) -> Result<()>
fn validate_state(&self, state: &Self::State) -> Result<()>
Checks state compatibility without mutating the component.
Sourcefn load_validated(&mut self, state: &Self::State)
fn load_validated(&mut self, state: &Self::State)
Restores state previously accepted by Self::validate_state.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".