Skip to main content

FileStore

Struct FileStore 

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

A file-backed WalStore: the default storage for Wal::open.

All reads and writes are positioned (pread/pwrite on Unix, seek_read/ seek_write on Windows), so concurrent appenders writing to disjoint offsets never contend on a shared file cursor, and a recovery read never disturbs an append. sync issues the platform’s true durability barrier: fdatasync on Linux, FlushFileBuffers on Windows, and fcntl(F_FULLFSYNC) on macOS — the last because macOS’s fsync does not flush the drive’s write cache.

Implementations§

Source§

impl FileStore

Source

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

Open the file at path, creating it if it does not exist.

The store does not interpret the file’s contents — it does not look for a torn tail or validate records. That is Wal::open’s job, which scans on open and truncates any incomplete trailing record.

§Errors

Returns WalError::Io if the file cannot be opened (for example a missing parent directory or insufficient permissions).

Source

pub fn path(&self) -> &Path

The path this store was opened from.

Trait Implementations§

Source§

impl Debug for FileStore

Source§

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

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

impl WalStore for FileStore

Source§

fn write_at(&self, offset: u64, bytes: &[u8]) -> Result<()>

Write bytes at byte offset, growing the store and zero-filling any gap if offset is beyond the current end.
Source§

fn read_at(&self, offset: u64, buf: &mut [u8]) -> Result<usize>

Read into buf starting at byte offset, returning the number of bytes read. Read more
Source§

fn truncate(&self, len: u64) -> Result<()>

Discard every byte at or after len, shrinking the store to exactly len bytes.
Source§

fn sync(&self) -> Result<()>

Flush every preceding write_at to stable storage. Read more
Source§

fn len(&self) -> Result<u64>

The current size of the store in bytes.
Source§

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

Whether the store holds no bytes. Read more
Source§

fn head(&self) -> Result<u64>

The lowest offset that still holds data. Read more
Source§

fn truncate_before(&self, _offset: u64) -> Result<u64>

Discard storage entirely below offset, if the backend can, returning the new head. 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.
Source§

impl<E> WithErrorCode<E> for E

Source§

fn with_code(self, code: impl Into<String>) -> CodedError<E>

Attach an error code to an error