Struct sanakirja::MutTxn

source ·
pub struct MutTxn<E: Borrow<Env>, T> { /* private fields */ }
Expand description

A mutable transaction.

Implementations§

source§

impl<E: Borrow<Env>, T> MutTxn<E, T>

source

pub fn env_borrow(&self) -> &Env

Borrow env

source§

impl<E: Borrow<Env>, T> MutTxn<E, T>

source

pub fn set_root(&mut self, num: usize, value: u64)

Setting the numth element of the initial page, treated as a [u64; 510], to value. This doesn’t actually write anything to that page, since that page is written during the commit.

In the current implementation, value is probably going to be the offset in the file of the root page of a B tree.

source

pub fn remove_root(&mut self, num: usize)

Setting the numth element of the initial page, treated as a [u64; 510].

source§

impl<E: Borrow<Env>, A> MutTxn<E, A>

source

pub unsafe fn root_page_mut(&mut self) -> &mut [u8; 4064]

The root page of this transaction (use with caution, this page contains root databases).

source

pub unsafe fn root_page(&self) -> &[u8; 4064]

The root page of this transaction.

source§

impl<E: Borrow<Env>, T> MutTxn<E, T>

source

pub fn root(&self, n: usize) -> Option<u64>

Low-level method to get the root page number n, if that page isn’t a B tree (use the RootDb trait else).

Trait Implementations§

source§

impl<E: Borrow<Env>, T> AllocPage for MutTxn<E, T>

source§

unsafe fn alloc_page(&mut self) -> Result<MutPage, Error>

Allocate a single page.

source§

unsafe fn alloc_page_no_dirty(&mut self) -> Result<MutPage, Error>

Allocate a single page.

source§

unsafe fn alloc_contiguous(&mut self, length: u64) -> Result<MutPage, Error>

Allocate many contiguous pages, return the first one

source§

fn incr_rc(&mut self, off: u64) -> Result<usize, Error>

Increment the reference count for page off.

source§

unsafe fn decr_rc(&mut self, off: u64) -> Result<usize, Error>

Decrement the page’s reference count, assuming the page was first allocated by another transaction. If the RC reaches 0, free the page. Must return the new RC (0 if freed).
source§

unsafe fn decr_rc_owned(&mut self, off: u64) -> Result<usize, Error>

Same as Self::decr_rc, but for pages allocated by the current transaction. This is an important distinction, as pages allocated by the current transaction can be reused immediately after being freed.
source§

impl<'a, E: Borrow<Env>, T> Commit for MutTxn<E, &'a mut MutTxn<E, T>>

The following is very easy, we’re just extending all values of the current transaction with values of the subtransaction.

source§

fn commit(self) -> Result<(), Error>

Commit the transaction.
source§

impl<E: Borrow<Env>> Commit for MutTxn<E, ()>

source§

fn commit(self) -> Result<(), Error>

Commit the transaction.
source§

impl<E: Borrow<Env>, T> Debug for MutTxn<E, T>

source§

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

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

impl<E: Borrow<Env>, T> Drop for MutTxn<E, T>

When dropping a transaction, we need to unlock the read-write locks internal to this process, and possibly the file locks.

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<E: Borrow<Env>, A> LoadPage for MutTxn<E, A>

§

type Error = Error

source§

unsafe fn load_page(&self, off: u64) -> Result<CowPage, Self::Error>

Loading a page.
source§

fn rc(&self, page: u64) -> Result<u64, Self::Error>

Reference-counting. Since reference-counts are designed to be storable into B trees by external allocators, pages referenced once aren’t stored, and hence are indistinguishable from pages that are never referenced. The default implementation returns 0. Read more
source§

unsafe fn load_page_contiguous( &self, _off: u64, _len: u64 ) -> Result<CowPage, Self::Error>

Loading multiple pages written contiguously in the underlying storage media. Read more
source§

impl<E: Borrow<Env>, T> RootDb for MutTxn<E, T>

source§

fn root_db<K: Storable + ?Sized, V: Storable + ?Sized, P: BTreePage<K, V>>( &self, n: usize ) -> Option<Db_<K, V, P>>

Return the database stored in the root page of the current transaction at index n, if any.
source§

impl<E: Borrow<Env>, T> RootPage for MutTxn<E, T>

source§

unsafe fn root_page(&self) -> &[u8; 4064]

The root page of this transaction.

Auto Trait Implementations§

§

impl<E, T> Freeze for MutTxn<E, T>
where E: Freeze, T: Freeze,

§

impl<E, T> RefUnwindSafe for MutTxn<E, T>

§

impl<E, T> Send for MutTxn<E, T>
where E: Send, T: Send,

§

impl<E, T> Sync for MutTxn<E, T>
where E: Sync, T: Sync,

§

impl<E, T> Unpin for MutTxn<E, T>
where E: Unpin, T: Unpin,

§

impl<E, T> UnwindSafe for MutTxn<E, T>
where E: UnwindSafe, T: UnwindSafe,

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>,

§

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>,

§

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.