Skip to main content

AppendLogSnapshot

Struct AppendLogSnapshot 

Source
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

Source

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.

Source

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

Source§

fn load(path: &Path) -> Result<(WatchCursor, Self), SnapshotError>

Open (or resume) the store at path. Read more
Source§

fn apply( &mut self, batch: &[KvUpdate], cursor: &WatchCursor, ) -> Result<(), SnapshotError>

Atomically fold batch into the store and advance the resume cursor. Read more
Source§

fn get(&self, key: &str) -> Result<Option<KvEntry>, SnapshotError>

Look up the live entry for key. None if absent or deleted.
Source§

fn range(&self, prefix: &str) -> Result<Vec<KvEntry>, SnapshotError>

All live entries whose key starts with prefix, in ascending key order. Read more
Source§

fn cursor(&self) -> WatchCursor

The most recently applied (and durably persisted) resume cursor — WatchCursor::none when nothing has been applied.
Source§

fn export_to( &mut self, dest_dir: &Path, ) -> Result<ExportManifest, SnapshotError>

Export this fold as a transferable artifact directory at 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 more
Source§

fn for_each_in_range( &self, prefix: &str, f: impl FnMut(KvEntry) -> Result<(), SnapshotError>, ) -> Result<(), SnapshotError>

Stream every live entry whose key starts with prefix, in ascending key order, invoking f once per entry — without buffering the whole match set in memory. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more