pub struct Txn<'g, P: ImmutablePage<'g>, G: Guard<'g, P>> { /* private fields */ }
Expand description
Implementations§
Source§impl<'g, P: ImmutablePage<'g>, G: Guard<'g, P>> Txn<'g, P, G>
impl<'g, P: ImmutablePage<'g>, G: Guard<'g, P>> Txn<'g, P, G>
Sourcepub fn get(&'g self, key: &[u8]) -> Result<Option<&'g [u8]>>
pub fn get(&'g self, key: &[u8]) -> Result<Option<&'g [u8]>>
Retrieves the value associated with the given key.
§Parameters
key
: The key to search for.
§Returns
Ok(Some(value))
if the key is found.Ok(None)
if the key is not found.Err(TxnError)
if an error occurs during the tree traversal.
§Safety
The returned slice &[u8]
is valid as long as the transaction Txn
is alive, as it points directly into the memory-mapped region.
Sourcepub fn in_order_iter(&'g self) -> impl Iterator<Item = (&'g [u8], &'g [u8])>
pub fn in_order_iter(&'g self) -> impl Iterator<Item = (&'g [u8], &'g [u8])>
Returns an iterator over all key-value pairs in the database, in key order.
The iterator yields tuples of (&[u8], &[u8])
representing key-value pairs.
Sourcepub fn in_order_range_iter<R: RangeBounds<[u8]>>(
&'g self,
range: &R,
) -> impl Iterator<Item = (&'g [u8], &'g [u8])>
pub fn in_order_range_iter<R: RangeBounds<[u8]>>( &'g self, range: &R, ) -> impl Iterator<Item = (&'g [u8], &'g [u8])>
Returns an iterator over key-value pairs within the specified range, in key order.
§Parameters
range
: A range bound (e.g.,start_key..end_key
,..end_key
,start_key..
) that defines the keys to include in the iteration.
The iterator yields tuples of (&[u8], &[u8])
representing key-value pairs.
Source§impl<'t, 'd> Txn<'t, WriterPage<'t, 'd>, Writer<'d>>
impl<'t, 'd> Txn<'t, WriterPage<'t, 'd>, Writer<'d>>
Sourcepub fn commit(self)
pub fn commit(self)
Commits the transaction, making all changes permanent and visible to subsequent transactions.
If commit
is not called, the transaction will be automatically
aborted when it goes out of scope.
Sourcepub fn abort(self)
pub fn abort(self)
Aborts the transaction, discarding all changes made within it.
This is automatically called if the transaction goes out of scope
without Txn::commit
being called.