Skip to main content

Checkpointable

Trait Checkpointable 

Source
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.

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§

Source

type State: Clone + Serialize + DeserializeOwned

Owned serializable component state.

Required Methods§

Source

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

Captures the current component state.

Source

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

Checks state compatibility without mutating the component.

Source

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".

Implementations on Foreign Types§

Source§

impl Checkpointable for ()

Source§

type State = ()

Source§

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

Source§

fn validate_state(&self, _state: &Self::State) -> Result<()>

Source§

fn load_validated(&mut self, _state: &Self::State)

Implementors§