Skip to main content

FileStorage

Struct FileStorage 

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

File-backed Storage holding an advisory lock on its database.

Implementations§

Source§

impl FileStorage

Source

pub fn open( base: impl Into<PathBuf>, fsync: FsyncPolicy, ) -> Result<Self, HostError>

Opens (creating as needed) the database at base and takes the exclusive writer lock — one writer at a time. Readers do not take this lock (they pin a generation file via [pin_current_generation] instead), so a writer and any number of readers coexist across threads or processes (the versioned MVCC layout).

§Errors

HostError::Locked when another writer owns the lock; HostError::Io for filesystem failures.

Source

pub fn path(&self) -> &Path

The database base path.

Source

pub fn journal_bytes(&self) -> u64

Current journal size in bytes (drives the snapshot policy).

Trait Implementations§

Source§

impl Debug for FileStorage

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Storage for FileStorage

Source§

type Error = HostError

Implementation-specific failure (I/O error, host callback error…).
Source§

fn read_snapshot(&mut self) -> Result<Option<Vec<u8>>, HostError>

The full snapshot image, or None when no database exists yet (first run).
Source§

fn write_snapshot(&mut self, bytes: &[u8]) -> Result<(), HostError>

Atomically replaces the snapshot image.
Source§

fn read_journal(&mut self) -> Result<Vec<u8>, HostError>

All journal bytes accumulated since the last snapshot (empty is normal).
Source§

fn append_journal(&mut self, entry: &[u8]) -> Result<(), HostError>

Appends one framed journal entry (see crate::journal).
Source§

fn clear_journal(&mut self) -> Result<(), HostError>

Discards the journal (called after a successful snapshot).

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.