Skip to main content

Tx

Struct Tx 

Source
pub struct Tx<K: TransactionKind> { /* private fields */ }
Available on crate feature mdbx only.
Expand description

Wrapper for the libmdbx transaction.

Implementations§

Source§

impl<K: TransactionKind> Tx<K>

Source

pub const fn inner(&self) -> &Transaction<K>

Returns a reference to the inner libmdbx transaction.

Source

pub fn id(&self) -> Result<u64>

Gets this transaction ID.

Source

pub fn get_dbi_raw(&self, name: &str) -> Result<MDBX_dbi, DatabaseError>

Gets a table database handle by name if it exists, otherwise, check the database, opening the DB if it exists.

Source

pub fn get_dbi<T: Table>(&self) -> Result<MDBX_dbi, DatabaseError>

Gets a table database handle by name if it exists, otherwise, check the database, opening the DB if it exists.

Source

pub fn new_cursor<T: Table>(&self) -> Result<Cursor<K, T>, DatabaseError>

Create db Cursor

Trait Implementations§

Source§

impl<K: TransactionKind> DbTx for Tx<K>

Source§

fn cursor_dup_read<T: DupSort>( &self, ) -> Result<Self::DupCursor<T>, DatabaseError>

Iterate over read only values in database.

Source§

fn entries<T: Table>(&self) -> Result<usize, DatabaseError>

Returns number of entries in the table using cheap DB stats invocation.

Source§

fn disable_long_read_transaction_safety(&mut self)

Disables long-lived read transaction safety guarantees, such as backtrace recording and timeout.

Source§

type Cursor<T: Table> = Cursor<K, T>

Cursor type for this read-only transaction
Source§

type DupCursor<T: DupSort> = Cursor<K, T>

DupCursor type for this read-only transaction
Source§

fn get<T: Table>( &self, key: T::Key, ) -> Result<Option<<T as Table>::Value>, DatabaseError>

Get value by an owned key
Source§

fn get_by_encoded_key<T: Table>( &self, key: &<T::Key as Encode>::Encoded, ) -> Result<Option<T::Value>, DatabaseError>

Get value by a reference to the encoded key, especially useful for “raw” keys that encode to themselves like Address and B256. Doesn’t need to clone a reference key like get.
Source§

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

Commit for read only transaction will consume and free transaction and allows freeing of memory pages
Source§

fn abort(self)

Aborts transaction
Source§

fn cursor_read<T: Table>(&self) -> Result<Self::Cursor<T>, DatabaseError>

Iterate over read only values in table.
Source§

fn prefetch(&self, enabled: bool) -> &Self

Enables or disables best-effort read-ahead for this transaction. Read more
Source§

impl DbTxMut for Tx<RW>

Source§

type CursorMut<T: Table> = Cursor<RW, T>

Read-Write Cursor type
Source§

type DupCursorMut<T: DupSort> = Cursor<RW, T>

Read-Write DupCursor type
Source§

fn put<T: Table>( &self, key: T::Key, value: T::Value, ) -> Result<(), DatabaseError>

Put value to database
Source§

fn append<T: Table>( &self, key: T::Key, value: T::Value, ) -> Result<(), DatabaseError>

Append value with the largest key to database. This should have the same outcome as put, but databases like MDBX provide dedicated modes to make it much faster, typically from O(logN) down to O(1) thanks to no lookup.
Source§

fn delete<T: Table>( &self, key: T::Key, value: Option<T::Value>, ) -> Result<bool, DatabaseError>

Delete value from database
Source§

fn clear<T: Table>(&self) -> Result<(), DatabaseError>

Clears database.
Source§

fn cursor_write<T: Table>(&self) -> Result<Self::CursorMut<T>, DatabaseError>

Cursor mut
Source§

fn cursor_dup_write<T: DupSort>( &self, ) -> Result<Self::DupCursorMut<T>, DatabaseError>

DupCursor mut.
Source§

impl<K: Debug + TransactionKind> Debug for Tx<K>

Source§

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

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

impl TableImporter for Tx<RW>

§

fn import_table<T, R>(&self, source_tx: &R) -> Result<(), DatabaseError>
where T: Table, R: DbTx,

Imports all table data from another transaction.
§

fn import_table_with_range<T, R>( &self, source_tx: &R, from: Option<<T as Table>::Key>, to: <T as Table>::Key, ) -> Result<(), DatabaseError>
where T: Table, R: DbTx, <T as Table>::Key: Default,

Imports table data from another transaction within a range. Read more
§

fn import_dupsort<T, R>(&self, source_tx: &R) -> Result<(), DatabaseError>
where T: DupSort, R: DbTx,

Imports all dupsort data from another transaction.

Auto Trait Implementations§

§

impl<K> !Freeze for Tx<K>

§

impl<K> !RefUnwindSafe for Tx<K>

§

impl<K> !UnwindSafe for Tx<K>

§

impl<K> Send for Tx<K>
where Transaction<K>: Send, Option<MetricsHandler<K>>: Send,

§

impl<K> Sync for Tx<K>
where Transaction<K>: Sync, Option<MetricsHandler<K>>: Sync,

§

impl<K> Unpin for Tx<K>
where Transaction<K>: Unpin, Option<MetricsHandler<K>>: Unpin,

§

impl<K> UnsafeUnpin for Tx<K>
where Transaction<K>: UnsafeUnpin, Option<MetricsHandler<K>>: UnsafeUnpin,

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> DbTxUnwindExt for T
where T: DbTxMut,

§

fn unwind_table_by_num<T>(&self, num: u64) -> Result<usize, DatabaseError>
where T: Table<Key = u64>,

Unwind table by some number key. Returns number of rows unwound. Read more
§

fn unwind_table<T, F>( &self, key: u64, selector: F, ) -> Result<usize, DatabaseError>
where T: Table, F: FnMut(<T as Table>::Key) -> u64,

Unwind the table to a provided number key. Returns number of rows unwound. Read more
§

fn unwind_table_by_walker<T1, T2>( &self, range: impl RangeBounds<<T1 as Table>::Key>, ) -> Result<(), DatabaseError>
where T1: Table, T2: Table<Key = <T1 as Table>::Value>,

Unwind a table forward by a Walker on another table. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> MaybeDebug for T
where T: Debug,

§

impl<T> NonStaticAny for T
where T: ?Sized,

§

fn type_id(&self) -> TypeId

Returns the lifetime-erased type ID of self.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 64 bytes