Skip to main content

SnapshotStore

Trait SnapshotStore 

Source
pub trait SnapshotStore: Send + Sync {
    // Required methods
    fn load(&self) -> Result<Option<Vec<u8>>>;
    fn save(&self, bytes: &[u8]) -> Result<()>;
}
Expand description

Generic opaque-blob snapshot store used by services that persist their whole state as a single serialized document (DynamoDB tables, SQS queues, etc.). Unlike the fine-grained crate::s3::S3Store which tracks individual objects and streams bodies to disk, this trait is designed for services whose state is small enough to fit in memory and can be written as one atomic file.

Required Methods§

Source

fn load(&self) -> Result<Option<Vec<u8>>>

Load the latest snapshot, if one exists. Returns Ok(None) when there is nothing on disk yet (first boot).

Source

fn save(&self, bytes: &[u8]) -> Result<()>

Persist the given bytes as the new snapshot. Implementations must ensure the write is atomic (crash-safe) and durable.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§