Skip to main content

CheckpointCodec

Trait CheckpointCodec 

Source
pub trait CheckpointCodec<S: WorkflowState = State>: Send + Sync {
    // Required methods
    fn serialize(
        &self,
        cp: &Checkpoint<S>,
        graph_hash: u64,
    ) -> Result<CheckpointBlob, CheckpointStoreError>;
    fn deserialize(
        &self,
        blob: &CheckpointBlob,
        expected_hash: u64,
    ) -> Result<Checkpoint<S>, CheckpointStoreError>;
}
Expand description

Checkpoint 序列化/反序列化接口。

§泛型参数

  • S — 类型化状态(默认 State = HashMap,向后兼容)

Required Methods§

Source

fn serialize( &self, cp: &Checkpoint<S>, graph_hash: u64, ) -> Result<CheckpointBlob, CheckpointStoreError>

将 Checkpoint 序列化为二进制 Blob。

graph_hash 由调用方提供(从 Graph::hash_u64() 获取), 写入 Blob 作为 correctness invariant。

Source

fn deserialize( &self, blob: &CheckpointBlob, expected_hash: u64, ) -> Result<Checkpoint<S>, CheckpointStoreError>

从二进制 Blob 反序列化为 Checkpoint。

如果 Blob 中的 graph_hashexpected_hash 不匹配, 返回 CheckpointStoreError::GraphMismatch

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§