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
Required Methods§
Sourcefn serialize(
&self,
cp: &Checkpoint<S>,
graph_hash: u64,
) -> Result<CheckpointBlob, CheckpointStoreError>
fn serialize( &self, cp: &Checkpoint<S>, graph_hash: u64, ) -> Result<CheckpointBlob, CheckpointStoreError>
将 Checkpoint 序列化为二进制 Blob。
graph_hash 由调用方提供(从 Graph::hash_u64() 获取),
写入 Blob 作为 correctness invariant。
Sourcefn deserialize(
&self,
blob: &CheckpointBlob,
expected_hash: u64,
) -> Result<Checkpoint<S>, CheckpointStoreError>
fn deserialize( &self, blob: &CheckpointBlob, expected_hash: u64, ) -> Result<Checkpoint<S>, CheckpointStoreError>
从二进制 Blob 反序列化为 Checkpoint。
如果 Blob 中的 graph_hash 与 expected_hash 不匹配,
返回 CheckpointStoreError::GraphMismatch。
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".