pub trait Storage {
type Error: Debug;
// Required methods
fn read_snapshot(&mut self) -> Result<Option<Vec<u8>>, Self::Error>;
fn write_snapshot(&mut self, bytes: &[u8]) -> Result<(), Self::Error>;
fn read_journal(&mut self) -> Result<Vec<u8>, Self::Error>;
fn append_journal(&mut self, entry: &[u8]) -> Result<(), Self::Error>;
fn clear_journal(&mut self) -> Result<(), Self::Error>;
}Expand description
Where snapshot and journal bytes live.
The engine calls append_journal synchronously at the end of every
mutating operation — that call is the durability point. Fsync policy,
atomicity of write_snapshot (tmp + rename) and locking are the
implementation’s business, not the core’s.
Required Associated Types§
Required Methods§
Sourcefn read_snapshot(&mut self) -> Result<Option<Vec<u8>>, Self::Error>
fn read_snapshot(&mut self) -> Result<Option<Vec<u8>>, Self::Error>
The full snapshot image, or None when no database exists yet
(first run).
Sourcefn write_snapshot(&mut self, bytes: &[u8]) -> Result<(), Self::Error>
fn write_snapshot(&mut self, bytes: &[u8]) -> Result<(), Self::Error>
Atomically replaces the snapshot image.
Sourcefn read_journal(&mut self) -> Result<Vec<u8>, Self::Error>
fn read_journal(&mut self) -> Result<Vec<u8>, Self::Error>
All journal bytes accumulated since the last snapshot (empty is normal).
Sourcefn append_journal(&mut self, entry: &[u8]) -> Result<(), Self::Error>
fn append_journal(&mut self, entry: &[u8]) -> Result<(), Self::Error>
Appends one framed journal entry (see crate::journal).
Sourcefn clear_journal(&mut self) -> Result<(), Self::Error>
fn clear_journal(&mut self) -> Result<(), Self::Error>
Discards the journal (called after a successful snapshot).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".