pub trait CheckpointSerializer: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn serialize_bytes(&self, value: &Value) -> Result<Vec<u8>>;
fn deserialize_bytes(&self, bytes: &[u8]) -> Result<Value>;
}Expand description
Pluggable serialize/deserialize for checkpoint payloads.
The format name is stored alongside the payload in the backend so
stale checkpoints can be deserialized with the matching format on
restart. Mismatches surface as a clear error rather than corrupted
state.
Required Methods§
Sourcefn name(&self) -> &str
fn name(&self) -> &str
Stable identifier (e.g. "json", "cbor"). Stored next to the
payload so deserialization can pick the matching format.
Sourcefn serialize_bytes(&self, value: &Value) -> Result<Vec<u8>>
fn serialize_bytes(&self, value: &Value) -> Result<Vec<u8>>
Serialize an arbitrary Serialize value into bytes.
Sourcefn deserialize_bytes(&self, bytes: &[u8]) -> Result<Value>
fn deserialize_bytes(&self, bytes: &[u8]) -> Result<Value>
Deserialize bytes back into a serde_json::Value. The two-step
indirection (Value → final type) lets the trait stay non-generic
while still supporting S: Serialize + DeserializeOwned.