PersistenceEngine

Struct PersistenceEngine 

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

Persistence engine that manages async WAL writing

Implementations§

Source§

impl PersistenceEngine

Source

pub fn new<P: AsRef<Path>>( path: P, config: PersistenceConfig, ) -> Result<Self, StorageError>

Create a new persistence engine writing to a file

Source

pub fn with_writer<W: Write + Seek + Send + 'static>( writer: W, config: PersistenceConfig, ) -> Result<Self, StorageError>

Create a new persistence engine with a custom writer

Source

pub fn send(&self, op: WalOp) -> Result<Lsn, StorageError>

Send a WAL operation to be persisted

This method is non-blocking unless the channel is full (backpressure). Returns the LSN assigned to the entry.

In volatile mode, entries are not sent to the WAL - just an LSN is returned.

Source

pub fn send_entry(&self, entry: WalEntry) -> Result<Lsn, StorageError>

Send a pre-built WAL entry to be persisted

In volatile mode, entries are not sent to the WAL.

Source

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

Trigger an immediate flush of pending entries

This is non-blocking - it signals the writer thread to flush but doesn’t wait for completion.

Source

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

Flush pending entries and wait for completion

This blocks until all pending entries have been written to disk.

Source

pub fn sync_timeout(&self, timeout: Duration) -> Result<bool, StorageError>

Flush pending entries and wait for completion with timeout

Returns true if the flush completed within the timeout, false otherwise.

Source

pub fn next_lsn(&self) -> Lsn

Get the next LSN that will be assigned

Source

pub fn stats(&self) -> PersistenceStats

Get current statistics

Source

pub fn durability_mode(&self) -> DurabilityMode

Get the current durability mode

Source

pub fn config(&self) -> &PersistenceConfig

Get the current configuration

Source

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

Shutdown the persistence engine gracefully

This flushes all pending entries and waits for the writer thread to terminate.

Source

pub fn is_shutdown(&self) -> bool

Check if the engine has been shut down

Trait Implementations§

Source§

impl Debug for PersistenceEngine

Source§

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

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

impl Drop for PersistenceEngine

Source§

fn drop(&mut self)

Executes the destructor for this type. 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> 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