Skip to main content

Wal

Struct Wal 

Source
pub struct Wal { /* private fields */ }

Implementations§

Source§

impl Wal

Source

pub fn create(path: &Path) -> Result<Self>

Creates a fresh WAL file, truncating any existing one. Writes the header synchronously so a subsequent open sees a valid file even if the caller panics before appending any frames. Always takes an exclusive lock — create is a write operation by definition.

Source

pub fn open(path: &Path) -> Result<Self>

Opens an existing WAL file with an exclusive lock (read-write). Convenience wrapper around Wal::open_with_mode.

Source

pub fn open_with_mode(path: &Path, mode: AccessMode) -> Result<Self>

Opens an existing WAL file with the given access mode. In ReadOnly mode the file descriptor is opened read-only and the advisory lock is shared — multiple read-only openers may coexist. Walks every frame from the start, validates checksums, and builds the in-memory latest_frame index. A torn or corrupted frame is treated as the end of the log — its bytes and anything after stay on disk but are ignored by reads.

Source

pub fn header(&self) -> WalHeader

Source

pub fn frame_count(&self) -> usize

Source

pub fn last_commit_page_count(&self) -> Option<u32>

Source

pub fn load_committed_into( &mut self, dest: &mut HashMap<u32, Box<[u8; 4096]>>, ) -> Result<()>

Bulk-loads every committed page from the WAL into dest. Used by Pager::open to warm a WAL cache so subsequent reads don’t have to seek back into the WAL file. Uncommitted frames are skipped (same rule as read_page).

Source

pub fn append_frame( &mut self, page_num: u32, content: &[u8; 4096], commit_page_count: Option<u32>, ) -> Result<()>

Appends a new frame at the current end of file. commit_page_count of None writes a dirty (in-progress) frame; Some(n) writes a commit frame carrying the post-commit page count. On commit the frame is fsync’d; dirty frames are not — torn writes are recovered by the checksum check on next open.

Source

pub fn read_page(&mut self, page_num: u32) -> Result<Option<Box<[u8; 4096]>>>

Reads the most recent committed copy of a page from the WAL, or None if no committed frame has been written for this page since the last checkpoint. Uncommitted (dirty) frames are skipped — a reader must only see committed state.

Source

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

Truncates the WAL back to just the header and rolls the salt. Called by the checkpointer (Phase 4d) once it has applied accumulated frames to the main file.

Trait Implementations§

Source§

impl Debug for Wal

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Wal

§

impl RefUnwindSafe for Wal

§

impl Send for Wal

§

impl Sync for Wal

§

impl Unpin for Wal

§

impl UnsafeUnpin for Wal

§

impl UnwindSafe for Wal

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.