Skip to main content

weavatrix_memory/snapshot/
mod.rs

1mod compact;
2mod file;
3mod in_memory;
4
5pub use compact::CompactSnapshotCodec;
6pub use file::{FileSnapshotStore, SnapshotOptions};
7pub use in_memory::InMemorySnapshotStore;
8
9use crate::{error::Result, projection::ProjectionSnapshot};
10
11pub trait SnapshotStore<P> {
12    /// Saves an immutable projection snapshot.
13    ///
14    /// # Errors
15    ///
16    /// Returns persistence, codec, or conflicting-snapshot errors.
17    fn save(&mut self, snapshot: &ProjectionSnapshot<P>) -> Result<()>;
18
19    /// Loads the snapshot with the greatest global event position.
20    ///
21    /// # Errors
22    ///
23    /// Returns persistence, codec, or corruption errors.
24    fn load_latest(&self) -> Result<Option<ProjectionSnapshot<P>>>;
25}