Skip to main content

ReadTxn

Struct ReadTxn 

Source
pub struct ReadTxn<'db, F: FileBackend> { /* private fields */ }
Expand description

A read transaction.

Construct via ReadTxn::begin. Holds:

  1. A ReaderSnapshot pinning the WAL end-LSN at construction.
  2. An optional cross-process READER_LOCK byte (shared with other readers but not exclusive with writers — see docs/format.md § File locking).

Reads inside a ReadTxn see a consistent snapshot of the database; pending writes from a concurrent WriteTxn and frames committed AFTER ReadTxn::begin are invisible.

Implementations§

Source§

impl<'db, F: FileBackend> ReadTxn<'db, F>

Source

pub fn begin(env: &'db TxnEnv<F>) -> Result<Self>

Begin a new read transaction.

Acquires a cross-process reader-lock slot (if env.lock_file is Some) with the env’s default busy timeout, then takes a ReaderSnapshot from the pager. Readers do not contend with each other (31 shared slots) and do not contend with writers on the byte-range layer.

§Errors
Source

pub fn begin_with_timeout( env: &'db TxnEnv<F>, timeout: Duration, ) -> Result<Self>

As begin with a caller-supplied timeout.

§Errors

See begin.

Source

pub fn pinned_lsn(&self) -> Lsn

LSN this txn’s snapshot pinned. Diagnostic-only.

Source

pub fn read_page(&self, id: PageId) -> Result<Page>

Read page id consistent with the txn’s snapshot.

§Errors

As ReaderSnapshot::read_page.

Source

pub fn snapshot(&self) -> &ReaderSnapshot<F>

Access the underlying snapshot. Used by obj::Db (M6 issue #47) to dispatch typed reads on a read txn.

Source

pub fn env(&self) -> &TxnEnv<F>

Access the env this txn lives in. Used by obj::Db to access the pager mutex.

Source

pub fn end(self)

Drop the txn explicitly (releases the snapshot pin and the reader lock).

Trait Implementations§

Source§

impl<'db, F: Debug + FileBackend> Debug for ReadTxn<'db, F>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'db, F> Freeze for ReadTxn<'db, F>

§

impl<'db, F> RefUnwindSafe for ReadTxn<'db, F>

§

impl<'db, F> Send for ReadTxn<'db, F>
where F: Send,

§

impl<'db, F> Sync for ReadTxn<'db, F>
where F: Send,

§

impl<'db, F> Unpin for ReadTxn<'db, F>

§

impl<'db, F> UnsafeUnpin for ReadTxn<'db, F>

§

impl<'db, F> UnwindSafe for ReadTxn<'db, F>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V