Skip to main content

WalManager

Struct WalManager 

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

WAL Manager — high-level interface for WAL operations.

Wraps a WalWriter and WalReader over a single WAL file. The manager provides the crash-recovery entry point (replay) and common lifecycle operations (flush, rotate, truncate).

Implementations§

Source§

impl WalManager

Source

pub fn open<P: AsRef<Path>>(path: P, fsync_policy: FsyncPolicy) -> Result<Self>

Open or create a WAL at path.

Creates any missing parent directories. The WAL file is opened for append-only writes; an existing file is not truncated.

Source

pub fn write(&mut self, entry: &WalEntry) -> Result<()>

Append an entry to the WAL.

Source

pub fn write_buffered(&mut self, entry: &WalEntry) -> Result<()>

Append an entry WITHOUT fsyncing (#170 group commit) — durability deferred to a later flush. Only for writes gated on a later durable marker (MVCC-Tier-1 staged rows). See WalWriter::write_buffered.

Source

pub fn flush(&mut self) -> Result<()>

Flush buffered bytes to disk (fsync).

Source

pub fn replay<F>(&mut self, callback: F) -> Result<Vec<WalEntry>>
where F: FnMut(&WalEntry) -> Result<()>,

Replay every entry from the WAL in file order, passing each to callback.

The replay is schema-blind: entries are returned as WalEntry values carrying opaque Raw payloads. No decode step is applied. Stops at the first corrupt or incomplete entry (torn tail) and returns the entries recovered up to that point.

Source

pub fn truncate(&mut self) -> Result<()>

Truncate the WAL, removing all entries.

Source

pub fn truncate_to(&mut self, offset: u64) -> Result<()>

Truncate the WAL to a specific byte offset, dropping every byte after it (MVCC Tier 1 transaction rollback).

Unlike truncate (which clears the whole log), this rolls the file back to a previously-recorded size mark, so a committed WAL prefix survives and only the aborted transaction’s staged records are discarded. A no-op if offset is already >= the current length.

Source

pub fn rotate(&mut self) -> Result<PathBuf>

Rotate the WAL: archive the current file under a timestamped name and start a fresh, empty WAL at the original path.

Returns the path of the archived WAL file.

Source

pub fn is_empty(&self) -> Result<bool>

Returns true if the WAL file contains no entries (file length is 0).

Source

pub fn size(&self) -> Result<u64>

Returns the size of the WAL file in bytes.

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.