Skip to main content

FileStore

Struct FileStore 

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

On-disk store: a real file wrapped in a fixed-size page cache.

This keeps the public FileStore name stable while introducing the 0.11.0 pager/buffer-pool boundary via [crate::pager::PagedStore].

Implementations§

Source§

impl FileStore

Source

pub fn new(file: File) -> Self

Source

pub fn open_locked( path: impl AsRef<Path>, mode: OpenMode, ) -> Result<Self, DbError>

Open a file store and acquire the process-level lock for the database path.

Locking policy (cross-process):

  • ReadWrite: takes an exclusive advisory lock on the sidecar file <db_path>.writer.lock (fail-fast; does not block indefinitely).
  • ReadOnly: opens the database read-only and takes a shared advisory lock on the same sidecar file. This prevents new writers from opening while readers are active.

This excludes concurrent writers, but does not prevent read-only opens while a writer is active. Callers that require stronger coordination should implement it at a higher layer.

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 Store for FileStore

Source§

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

Source§

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

Source§

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

Source§

fn sync(&mut self) -> Result<(), DbError>

Source§

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

Shrink or grow the logical file to len bytes (used for crash recovery truncation).
Source§

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

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.