Skip to main content

DbTx

Trait DbTx 

Source
pub trait DbTx: Debug + Send {
    type Cursor<T: Table>: DbCursorRO<T> + Send;
    type DupCursor<T: DupSort>: DbDupCursorRO<T> + DbCursorRO<T> + Send;

    // Required methods
    fn get<T: Table>(
        &self,
        key: T::Key,
    ) -> Result<Option<T::Value>, DatabaseError>;
    fn get_by_encoded_key<T: Table>(
        &self,
        key: &<T::Key as Encode>::Encoded,
    ) -> Result<Option<T::Value>, DatabaseError>;
    fn commit(self) -> Result<(), DatabaseError>;
    fn abort(self);
    fn cursor_read<T: Table>(&self) -> Result<Self::Cursor<T>, DatabaseError>;
    fn cursor_dup_read<T: DupSort>(
        &self,
    ) -> Result<Self::DupCursor<T>, DatabaseError>;
    fn entries<T: Table>(&self) -> Result<usize, DatabaseError>;
    fn disable_long_read_transaction_safety(&mut self);
}
Expand description

Read only transaction

Required Associated Types§

Source

type Cursor<T: Table>: DbCursorRO<T> + Send

Cursor type for this read-only transaction

Source

type DupCursor<T: DupSort>: DbDupCursorRO<T> + DbCursorRO<T> + Send

DupCursor type for this read-only transaction

Required Methods§

Source

fn get<T: Table>(&self, key: T::Key) -> Result<Option<T::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 cursor_dup_read<T: DupSort>( &self, ) -> Result<Self::DupCursor<T>, DatabaseError>

Iterate over read only values in dup sorted table.

Source

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

Returns number of entries in the table.

Source

fn disable_long_read_transaction_safety(&mut self)

Disables long-lived read transaction safety guarantees.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§