Skip to main content

DynOperatorState

Trait DynOperatorState 

Source
pub trait DynOperatorState: Send + Sync {
    // Required methods
    fn snapshot_boxed(
        &self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + '_>>;
    fn restore_boxed<'a>(
        &'a self,
        snapshot: &'a [u8],
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>;
}
Expand description

Object-safe (dyn-compatible) adapter over OperatorState.

OperatorState uses return-position impl Future (RPITIT), which is not dyn-safe, so it cannot be stored behind Arc<dyn OperatorState>. This adapter boxes the returned futures so heterogeneous operator states can be registered with the CheckpointCoordinator for real state capture and recovery. A blanket implementation is provided for every T: OperatorState, so any concrete operator state works automatically via Arc::new(state) as Arc<dyn DynOperatorState>.

Required Methods§

Source

fn snapshot_boxed( &self, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + '_>>

Snapshot the state, returning a boxed future.

Source

fn restore_boxed<'a>( &'a self, snapshot: &'a [u8], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>

Restore from a snapshot, returning a boxed future.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§