Files
zesdex/src/app/state/snapshot.rs
T

23 lines
527 B
Rust
Raw Normal View History

use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StateSnapshot {
pub snapshot: serde_json::Value,
}
impl StateSnapshot {
pub fn new() -> Self {
StateSnapshot {
snapshot: serde_json::json!({}),
}
}
}
pub fn serialize_snapshot(snapshot: &StateSnapshot) -> anyhow::Result<Vec<u8>> {
Ok(serde_json::to_vec(snapshot)?)
}
pub fn deserialize_snapshot(data: &[u8]) -> anyhow::Result<StateSnapshot> {
Ok(serde_json::from_slice(data)?)
}