Skip to main content

StorageEngine

Struct StorageEngine 

Source
pub struct StorageEngine { /* private fields */ }
Expand description

Single-writer durable KV storage composed from the log and rebuildable redb index.

Implementations§

Source§

impl StorageEngine

Source

pub fn open(path: impl AsRef<Path>) -> Result<OpenedStorage, StorageError>

Opens a data directory, verifies its log, and catches the index up before use.

§Errors

Returns an error for directory contention, log corruption, invalid committed mutations, a divergent index checkpoint, or filesystem failures.

Source

pub fn data_path(&self) -> &Path

Returns the owned data-directory path.

Source

pub fn backup( &self, destination: impl AsRef<Path>, ) -> Result<BackupInfo, BackupError>

Creates an atomic, independently verifiable backup at the current checkpoint.

§Errors

Returns an error when the snapshot cannot be created, the destination exists or is inside the live data directory, or synchronized promotion of the complete backup fails.

Source

pub fn write( &mut self, transaction_id: Uuid, mutations: &[Mutation], ) -> Result<AppendOutcome, StorageError>

Durably commits an atomic batch and then materializes it.

The log is synchronized before redb is updated. If redb fails, the error includes the durable commit receipt and this handle blocks reads and writes until reopen replays the log.

§Errors

Returns an error for invalid mutations, idempotency conflicts, log I/O, or materialized-index failures.

Source

pub fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>, StorageError>

Reads a binary value from the caught-up materialized index.

§Errors

Returns an error for an empty or oversized key, an index read failure, or a handle made stale by a prior post-commit index failure.

Source

pub fn scan_page( &self, after: Option<&[u8]>, limit: usize, ) -> Result<KvPage, StorageError>

Scans one bounded page in strict binary-key order.

after is exclusive. A returned next_after is present only when at least one additional entry exists.

§Errors

Returns an error for a stale handle, invalid cursor key, invalid page size, or materialized-index failure.

Source

pub fn index_path(&self) -> PathBuf

Returns the internal materialized-index path for diagnostics.

Source

pub fn snapshot(&self) -> Result<SnapshotInfo, StorageError>

Creates or reuses a verified logical snapshot at the current index checkpoint.

§Errors

Returns an error when the live index is stale, cannot be streamed, or the snapshot cannot be synchronized, verified, and atomically promoted.

Source

pub fn compact(&mut self) -> Result<CompactionOutcome, StorageError>

Retires the active log prefix behind a verified logical snapshot.

The new empty segment is synchronized before an immutable manifest generation selects it. Physical deletion of the retired segment happens only after that commit and is reported independently.

§Errors

Returns an error while preparing the snapshot, segment, or manifest. A poisoned or stale handle must be reopened before compaction.

Trait Implementations§

Source§

impl Debug for StorageEngine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.