pub trait Snapshotable {
// Required methods
fn save_snapshot<W: Write>(
&self,
writer: W,
) -> Result<SnapshotMeta, SnapshotError>;
fn load_snapshot<R: Read>(
&mut self,
reader: R,
) -> Result<SnapshotMeta, SnapshotError>;
fn save_checkpoint<W: Write>(
&self,
writer: W,
wal_lsn: u64,
) -> Result<SnapshotMeta, SnapshotError>;
}Expand description
A backend that can serialize its state to a byte stream and restore from one.
The trait is deliberately orthogonal to [GraphStorage] /
[GraphStorageMut]: a backend opts into durability independently of the
core read/write contract. Future hooks (WAL, incremental checkpoints)
will land alongside this trait, not inside it — keeping Snapshotable
narrow makes it easy to compose (e.g. SnapshotOverS3, or a wrapper that
also appends to a WAL on every mutation).
Required Methods§
fn save_snapshot<W: Write>( &self, writer: W, ) -> Result<SnapshotMeta, SnapshotError>
fn load_snapshot<R: Read>( &mut self, reader: R, ) -> Result<SnapshotMeta, SnapshotError>
Sourcefn save_checkpoint<W: Write>(
&self,
writer: W,
wal_lsn: u64,
) -> Result<SnapshotMeta, SnapshotError>
fn save_checkpoint<W: Write>( &self, writer: W, wal_lsn: u64, ) -> Result<SnapshotMeta, SnapshotError>
Save a snapshot stamped with a WAL log position, suitable as a checkpoint fence. The fence is the LSN past which the WAL is the source of truth on recovery; replay skips records at or below it.
Required (no default) because a fence-less default would
silently break recovery for any backend that opted into a
WAL — every backend that implements Snapshotable must be
able to produce a checkpoint. The only in-tree impl
(InMemoryGraph) just calls write_snapshot with
Some(wal_lsn).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.