pub struct AppendLogSnapshot { /* private fields */ }Expand description
The append-only CRC log as a SnapshotStore (the default backend).
Wraps the existing SnapshotWriter + load machinery — same v2 on-disk
format, same CRC framing, same FDB-versionstamp-safe cursor encoding, so files
written by either path are mutually loadable. Keeps the whole fold in a
HashMap in RAM to serve get/range,
which is exactly what edge/tunnel-style consumers already do — small state,
pure Rust. A consumer that cannot hold its fold in RAM wants an on-disk
backend instead (e.g. the fjall feature).
Implementations§
Source§impl AppendLogSnapshot
impl AppendLogSnapshot
Sourcepub fn open(
path: &Path,
compact_threshold: u64,
) -> Result<(WatchCursor, Self), SnapshotError>
pub fn open( path: &Path, compact_threshold: u64, ) -> Result<(WatchCursor, Self), SnapshotError>
Open or resume the log at path with an explicit compaction threshold.
Replays any existing log into the in-RAM fold (and compacts it, exactly as
load does), then opens the writer for append. Returns the resume cursor
alongside the store.
Sourcepub fn import(
artifact_dir: &Path,
dest_path: &Path,
compact_threshold: u64,
) -> Result<(WatchCursor, Self), SnapshotError>
pub fn import( artifact_dir: &Path, dest_path: &Path, compact_threshold: u64, ) -> Result<(WatchCursor, Self), SnapshotError>
Import an exported artifact (see SnapshotStore::export_to) as a new
fold at dest_path, returning the embedded resume cursor and the opened
store.
dest_path is a file path (this backend is a single log file) and
must not already exist. The artifact is fully verified against its
manifest — checksums, backend identity, format generation — and the
staged copy is loaded and its cursor compared against the manifest’s
before anything lands at dest_path; a bad artifact never becomes a
fold. A crash mid-import leaves nothing at dest_path; a crash after
the final rename leaves a valid fold (a retried import then refuses the
existing destination — just open it).
Trait Implementations§
Source§impl SnapshotStore for AppendLogSnapshot
impl SnapshotStore for AppendLogSnapshot
Source§fn load(path: &Path) -> Result<(WatchCursor, Self), SnapshotError>
fn load(path: &Path) -> Result<(WatchCursor, Self), SnapshotError>
path. Read moreSource§fn apply(
&mut self,
batch: &[KvUpdate],
cursor: &WatchCursor,
) -> Result<(), SnapshotError>
fn apply( &mut self, batch: &[KvUpdate], cursor: &WatchCursor, ) -> Result<(), SnapshotError>
batch into the store and advance the resume cursor. Read moreSource§fn get(&self, key: &str) -> Result<Option<KvEntry>, SnapshotError>
fn get(&self, key: &str) -> Result<Option<KvEntry>, SnapshotError>
key. None if absent or deleted.Source§fn range(&self, prefix: &str) -> Result<Vec<KvEntry>, SnapshotError>
fn range(&self, prefix: &str) -> Result<Vec<KvEntry>, SnapshotError>
prefix, in ascending key order. Read moreSource§fn cursor(&self) -> WatchCursor
fn cursor(&self) -> WatchCursor
WatchCursor::none when nothing has been applied.Source§fn export_to(
&mut self,
dest_dir: &Path,
) -> Result<ExportManifest, SnapshotError>
fn export_to( &mut self, dest_dir: &Path, ) -> Result<ExportManifest, SnapshotError>
dest_dir:
the backend’s files under data/ plus a MANIFEST.json carrying
per-file checksums, the backend’s identity and on-disk format generation,
and the watch cursor the payload is exactly consistent with
(== cursor at the moment of export). Read moreSource§fn for_each_in_range(
&self,
prefix: &str,
f: impl FnMut(KvEntry) -> Result<(), SnapshotError>,
) -> Result<(), SnapshotError>
fn for_each_in_range( &self, prefix: &str, f: impl FnMut(KvEntry) -> Result<(), SnapshotError>, ) -> Result<(), SnapshotError>
prefix, in ascending key
order, invoking f once per entry — without buffering the whole match
set in memory. Read more