Trait mmtkvdb::Txn

source ·
pub trait Txn {
Show 34 methods // Required methods fn get<'kr, K, V, C, KRef>( &self, db: &Db<K, V, C>, key: KRef ) -> Result<Option<V::AlignedRef<'_>>> where K: ?Sized + Storable + 'kr, V: ?Sized + Storable, C: Constraint, KRef: StorableRef<'kr, K>; fn new_cursor<K, V, C>(&self, db: &Db<K, V, C>) -> Result<Cursor<K, V, C>> where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint; fn cursor_get_current_value_count<K, V>( &self, cursor: &Cursor<K, V, KeysDuplicate> ) -> Result<usize> where K: ?Sized + Storable, V: ?Sized + Storable; fn cursor_set_first<K, V, C>( &self, cursor: &Cursor<K, V, C> ) -> Result<bool> where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint; fn cursor_set_first_get_pair<K, V, C>( &self, cursor: &Cursor<K, V, C> ) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>> where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint; fn cursor_set_last<K, V, C>(&self, cursor: &Cursor<K, V, C>) -> Result<bool> where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint; fn cursor_set_last_get_pair<K, V, C>( &self, cursor: &Cursor<K, V, C> ) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>> where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint; fn cursor_get_current_key<K, V, C>( &self, cursor: &Cursor<K, V, C> ) -> Result<Option<K::AlignedRef<'_>>> where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint; fn cursor_get_current_value<K, V, C>( &self, cursor: &Cursor<K, V, C> ) -> Result<Option<V::AlignedRef<'_>>> where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint; fn cursor_get_current_pair<K, V, C>( &self, cursor: &Cursor<K, V, C> ) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>> where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint; fn cursor_set_key<'kr, K, V, C, KRef>( &self, cursor: &Cursor<K, V, C>, key: KRef ) -> Result<bool> where K: ?Sized + Storable + 'kr, V: ?Sized + Storable, C: Constraint, KRef: StorableRef<'kr, K>; fn cursor_set_key_get_value<'kr, K, V, C, KRef>( &self, cursor: &Cursor<K, V, C>, key: KRef ) -> Result<Option<V::AlignedRef<'_>>> where K: ?Sized + Storable + 'kr, V: ?Sized + Storable, C: Constraint, KRef: StorableRef<'kr, K>; fn cursor_search_key<'kr, K, V, C, KRef>( &self, cursor: &Cursor<K, V, C>, key: KRef ) -> Result<bool> where K: ?Sized + Storable + 'kr, V: ?Sized + Storable, C: Constraint, KRef: StorableRef<'kr, K>; fn cursor_search_key_get_pair<'kr, K, V, C, KRef>( &self, cursor: &Cursor<K, V, C>, key: KRef ) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>> where K: ?Sized + Storable + 'kr, V: ?Sized + Storable, C: Constraint, KRef: StorableRef<'kr, K>; fn cursor_set_next<K, V, C>(&self, cursor: &Cursor<K, V, C>) -> Result<bool> where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint; fn cursor_set_next_get_pair<K, V, C>( &self, cursor: &Cursor<K, V, C> ) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>> where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint; fn cursor_set_prev<K, V, C>(&self, cursor: &Cursor<K, V, C>) -> Result<bool> where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint; fn cursor_set_prev_get_pair<K, V, C>( &self, cursor: &Cursor<K, V, C> ) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>> where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint; fn cursor_set_next_key<K, V, C>( &self, cursor: &Cursor<K, V, C> ) -> Result<bool> where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint; fn cursor_set_next_key_get_pair<K, V, C>( &self, cursor: &Cursor<K, V, C> ) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>> where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint; fn cursor_set_prev_key<K, V, C>( &self, cursor: &Cursor<K, V, C> ) -> Result<bool> where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint; fn cursor_set_prev_key_get_pair<K, V, C>( &self, cursor: &Cursor<K, V, C> ) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>> where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint; fn cursor_set_first_value<K, V>( &self, cursor: &Cursor<K, V, KeysDuplicate> ) -> Result<bool> where K: ?Sized + Storable, V: ?Sized + Storable; fn cursor_set_first_value_get_value<K, V>( &self, cursor: &Cursor<K, V, KeysDuplicate> ) -> Result<Option<V::AlignedRef<'_>>> where K: ?Sized + Storable, V: ?Sized + Storable; fn cursor_set_last_value<K, V>( &self, cursor: &Cursor<K, V, KeysDuplicate> ) -> Result<bool> where K: ?Sized + Storable, V: ?Sized + Storable; fn cursor_set_last_value_get_value<K, V>( &self, cursor: &Cursor<K, V, KeysDuplicate> ) -> Result<Option<V::AlignedRef<'_>>> where K: ?Sized + Storable, V: ?Sized + Storable; fn cursor_set_pair<'kr, 'vr, K, V, KRef, VRef>( &self, cursor: &Cursor<K, V, KeysDuplicate>, key: KRef, value: VRef ) -> Result<bool> where K: ?Sized + Storable + 'kr, V: ?Sized + Storable + 'vr, KRef: StorableRef<'kr, K>, VRef: StorableRef<'vr, V>; fn cursor_set_key_search_value<'kr, 'vr, K, V, KRef, VRef>( &self, cursor: &Cursor<K, V, KeysDuplicate>, key: KRef, value: VRef ) -> Result<bool> where K: ?Sized + Storable + 'kr, V: ?Sized + Storable + 'vr, KRef: StorableRef<'kr, K>, VRef: StorableRef<'vr, V>; fn cursor_set_key_search_value_get_value<'kr, 'vr, K, V, KRef, VRef>( &self, cursor: &Cursor<K, V, KeysDuplicate>, key: KRef, value: VRef ) -> Result<Option<V::AlignedRef<'_>>> where K: ?Sized + Storable + 'kr, V: ?Sized + Storable + 'vr, KRef: StorableRef<'kr, K>, VRef: StorableRef<'vr, V>; fn cursor_set_next_value<K, V>( &self, cursor: &Cursor<K, V, KeysDuplicate> ) -> Result<bool> where K: ?Sized + Storable, V: ?Sized + Storable; fn cursor_set_next_value_get_value<K, V>( &self, cursor: &Cursor<K, V, KeysDuplicate> ) -> Result<Option<V::AlignedRef<'_>>> where K: ?Sized + Storable, V: ?Sized + Storable; fn cursor_set_prev_value<K, V>( &self, cursor: &Cursor<K, V, KeysDuplicate> ) -> Result<bool> where K: ?Sized + Storable, V: ?Sized + Storable; fn cursor_set_prev_value_get_value<K, V>( &self, cursor: &Cursor<K, V, KeysDuplicate> ) -> Result<Option<V::AlignedRef<'_>>> where K: ?Sized + Storable, V: ?Sized + Storable; // Provided method fn get_owned<'a, 'kr, K, V, C, KRef>( &'a self, db: &Db<K, V, C>, key: KRef ) -> Result<Option<<V as ToOwned>::Owned>> where K: ?Sized + Storable + 'kr, V: ?Sized + Storable + ToOwned, C: Constraint, KRef: StorableRef<'kr, K> { ... }
}
Expand description

Read-write or read-only transaction

This trait provides the methods for read-access to databases. The simplest interface is provided by Txn::get, which returns a reference to the stored value for a given key (or None if the key does not exist). If an owned value is desired, use Txn::get_owned instead, which automatically converts the reference (e.g. &str) into an owned value (e.g. String) using GenericCow::into_owned.

Txn::get and Txn::get_owned will only retrieve the first value in case of duplicate keys. For more sophisticated access, use Txn::new_cursor to create a new Cursor which then can be used with one of the cursor methods in the Txn trait (or the TxnRw struct in case of write access, respectively).

Required Methods§

source

fn get<'kr, K, V, C, KRef>( &self, db: &Db<K, V, C>, key: KRef ) -> Result<Option<V::AlignedRef<'_>>>where K: ?Sized + Storable + 'kr, V: ?Sized + Storable, C: Constraint, KRef: StorableRef<'kr, K>,

Get reference to value in database

source

fn new_cursor<K, V, C>(&self, db: &Db<K, V, C>) -> Result<Cursor<K, V, C>>where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint,

Create a new cursor

source

fn cursor_get_current_value_count<K, V>( &self, cursor: &Cursor<K, V, KeysDuplicate> ) -> Result<usize>where K: ?Sized + Storable, V: ?Sized + Storable,

Get number of values for current cursor position

source

fn cursor_set_first<K, V, C>(&self, cursor: &Cursor<K, V, C>) -> Result<bool>where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint,

Set cursor to first entry in database

Returns false if database is empty.

source

fn cursor_set_first_get_pair<K, V, C>( &self, cursor: &Cursor<K, V, C> ) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>>where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint,

Set cursor to first entry in database and get pair

source

fn cursor_set_last<K, V, C>(&self, cursor: &Cursor<K, V, C>) -> Result<bool>where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint,

Set cursor to last entry in database

Returns false if database is empty.

source

fn cursor_set_last_get_pair<K, V, C>( &self, cursor: &Cursor<K, V, C> ) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>>where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint,

Set cursor to last entry in database and get pair

source

fn cursor_get_current_key<K, V, C>( &self, cursor: &Cursor<K, V, C> ) -> Result<Option<K::AlignedRef<'_>>>where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint,

Get key at current cursor position

source

fn cursor_get_current_value<K, V, C>( &self, cursor: &Cursor<K, V, C> ) -> Result<Option<V::AlignedRef<'_>>>where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint,

Get value at current cursor position

source

fn cursor_get_current_pair<K, V, C>( &self, cursor: &Cursor<K, V, C> ) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>>where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint,

Get key-value pair at current cursor position

source

fn cursor_set_key<'kr, K, V, C, KRef>( &self, cursor: &Cursor<K, V, C>, key: KRef ) -> Result<bool>where K: ?Sized + Storable + 'kr, V: ?Sized + Storable, C: Constraint, KRef: StorableRef<'kr, K>,

Set cursor to key

Returns false if key does not exist. Note that in this case it’s not guaranteed that subsequent accesses to the cursor using cursor_get_current_ methods return None.

source

fn cursor_set_key_get_value<'kr, K, V, C, KRef>( &self, cursor: &Cursor<K, V, C>, key: KRef ) -> Result<Option<V::AlignedRef<'_>>>where K: ?Sized + Storable + 'kr, V: ?Sized + Storable, C: Constraint, KRef: StorableRef<'kr, K>,

Set cursor to key and get value

source

fn cursor_search_key<'kr, K, V, C, KRef>( &self, cursor: &Cursor<K, V, C>, key: KRef ) -> Result<bool>where K: ?Sized + Storable + 'kr, V: ?Sized + Storable, C: Constraint, KRef: StorableRef<'kr, K>,

Set cursor to key or next greater key if not existent

Returns false if no matching key has been found. Note that in this case it’s not guaranteed that subsequent accesses to the cursor using cursor_get_current_ methods return None.

source

fn cursor_search_key_get_pair<'kr, K, V, C, KRef>( &self, cursor: &Cursor<K, V, C>, key: KRef ) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>>where K: ?Sized + Storable + 'kr, V: ?Sized + Storable, C: Constraint, KRef: StorableRef<'kr, K>,

Set cursor to key or next greater key if not existent and get pair

source

fn cursor_set_next<K, V, C>(&self, cursor: &Cursor<K, V, C>) -> Result<bool>where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint,

Move cursor to next entry in database

Returns false if there is no next entry. Note that in this case it’s not guaranteed that subsequent accesses to the cursor using cursor_get_current_ methods return None.

source

fn cursor_set_next_get_pair<K, V, C>( &self, cursor: &Cursor<K, V, C> ) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>>where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint,

Move cursor to next entry in database and get pair

source

fn cursor_set_prev<K, V, C>(&self, cursor: &Cursor<K, V, C>) -> Result<bool>where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint,

Move cursor to previous entry in database

Returns false if there is no previous entry. Note that in this case it’s not guaranteed that subsequent accesses to the cursor using cursor_get_current_ methods return None.

source

fn cursor_set_prev_get_pair<K, V, C>( &self, cursor: &Cursor<K, V, C> ) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>>where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint,

Move cursor to previous entry in database and get pair

source

fn cursor_set_next_key<K, V, C>(&self, cursor: &Cursor<K, V, C>) -> Result<bool>where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint,

Move cursor to first value of next key

Returns false if there is no next key. Note that in this case it’s not guaranteed that subsequent accesses to the cursor using cursor_get_current_ methods return None.

source

fn cursor_set_next_key_get_pair<K, V, C>( &self, cursor: &Cursor<K, V, C> ) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>>where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint,

Move cursor to first value of next key and get pair

source

fn cursor_set_prev_key<K, V, C>(&self, cursor: &Cursor<K, V, C>) -> Result<bool>where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint,

Move cursor to last value of previous key

Returns false if there is no previous key. Note that in this case it’s not guaranteed that subsequent accesses to the cursor using cursor_get_current_ methods return None.

source

fn cursor_set_prev_key_get_pair<K, V, C>( &self, cursor: &Cursor<K, V, C> ) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>>where K: ?Sized + Storable, V: ?Sized + Storable, C: Constraint,

Move cursor to last value of previous key and get pair

source

fn cursor_set_first_value<K, V>( &self, cursor: &Cursor<K, V, KeysDuplicate> ) -> Result<bool>where K: ?Sized + Storable, V: ?Sized + Storable,

Move cursor to first value of current key

Returns false if no value has been found. Note that in this case it’s not guaranteed that subsequent accesses to the cursor using cursor_get_current_ methods return None.

source

fn cursor_set_first_value_get_value<K, V>( &self, cursor: &Cursor<K, V, KeysDuplicate> ) -> Result<Option<V::AlignedRef<'_>>>where K: ?Sized + Storable, V: ?Sized + Storable,

Move cursor to first value of current key and get value

source

fn cursor_set_last_value<K, V>( &self, cursor: &Cursor<K, V, KeysDuplicate> ) -> Result<bool>where K: ?Sized + Storable, V: ?Sized + Storable,

Move cursor to last value of current key

Returns false if no value has been found. Note that in this case it’s not guaranteed that subsequent accesses to the cursor using cursor_get_current_ methods return None.

source

fn cursor_set_last_value_get_value<K, V>( &self, cursor: &Cursor<K, V, KeysDuplicate> ) -> Result<Option<V::AlignedRef<'_>>>where K: ?Sized + Storable, V: ?Sized + Storable,

Move cursor to last value of current key and get value

source

fn cursor_set_pair<'kr, 'vr, K, V, KRef, VRef>( &self, cursor: &Cursor<K, V, KeysDuplicate>, key: KRef, value: VRef ) -> Result<bool>where K: ?Sized + Storable + 'kr, V: ?Sized + Storable + 'vr, KRef: StorableRef<'kr, K>, VRef: StorableRef<'vr, V>,

Set cursor to key-value pair

Returns false if not found. Note that in this case it’s not guaranteed that subsequent accesses to the cursor using cursor_get_current_ methods return None.

source

fn cursor_set_key_search_value<'kr, 'vr, K, V, KRef, VRef>( &self, cursor: &Cursor<K, V, KeysDuplicate>, key: KRef, value: VRef ) -> Result<bool>where K: ?Sized + Storable + 'kr, V: ?Sized + Storable + 'vr, KRef: StorableRef<'kr, K>, VRef: StorableRef<'vr, V>,

Set cursor to key and value or next greater value if not existent

Returns false if no matching value has been found for the given key. Note that in this case it’s not guaranteed that subsequent accesses to the cursor using cursor_get_current_ methods return None.

source

fn cursor_set_key_search_value_get_value<'kr, 'vr, K, V, KRef, VRef>( &self, cursor: &Cursor<K, V, KeysDuplicate>, key: KRef, value: VRef ) -> Result<Option<V::AlignedRef<'_>>>where K: ?Sized + Storable + 'kr, V: ?Sized + Storable + 'vr, KRef: StorableRef<'kr, K>, VRef: StorableRef<'vr, V>,

Set cursor to key and value or next greater value if not existent and get value

source

fn cursor_set_next_value<K, V>( &self, cursor: &Cursor<K, V, KeysDuplicate> ) -> Result<bool>where K: ?Sized + Storable, V: ?Sized + Storable,

Move cursor to next value of current key

Returns false if there is no next value for the current key. Note that in this case it’s not guaranteed that subsequent accesses to the cursor using cursor_get_current_ methods return None.

source

fn cursor_set_next_value_get_value<K, V>( &self, cursor: &Cursor<K, V, KeysDuplicate> ) -> Result<Option<V::AlignedRef<'_>>>where K: ?Sized + Storable, V: ?Sized + Storable,

Move cursor to next value of current key and get value

source

fn cursor_set_prev_value<K, V>( &self, cursor: &Cursor<K, V, KeysDuplicate> ) -> Result<bool>where K: ?Sized + Storable, V: ?Sized + Storable,

Move cursor to next value of current key

Returns false if there is no previous value for the current key. Note that in this case it’s not guaranteed that subsequent accesses to the cursor using cursor_get_current_ methods return None.

source

fn cursor_set_prev_value_get_value<K, V>( &self, cursor: &Cursor<K, V, KeysDuplicate> ) -> Result<Option<V::AlignedRef<'_>>>where K: ?Sized + Storable, V: ?Sized + Storable,

Move cursor to next value of current key and get value

Provided Methods§

source

fn get_owned<'a, 'kr, K, V, C, KRef>( &'a self, db: &Db<K, V, C>, key: KRef ) -> Result<Option<<V as ToOwned>::Owned>>where K: ?Sized + Storable + 'kr, V: ?Sized + Storable + ToOwned, C: Constraint, KRef: StorableRef<'kr, K>,

Get owned value from database

Implementors§

source§

impl<'a> Txn for TxnRo<'a>

source§

impl<'a> Txn for TxnRw<'a>