Skip to main content

weavatrix_memory/
snapshot.rs

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