pub struct TxnRw<'a> { /* private fields */ }
Expand description
Read-write transaction
A read-write transaction can be started with EnvRw::txn_rw
.
The methods for read-only access to the database are accessible through the
Txn
trait (which is implemented by TxnRo
and TxnRw
).
Methods for write access, however, are available directly on the TxnRw
struct.
Read-write transactions are aborted when dropped. To make
changes permanent, TxnRw::commit
must be called.
Implementations
sourceimpl<'a> TxnRw<'a>
impl<'a> TxnRw<'a>
sourcepub fn nested(&mut self) -> Result<TxnRw<'_>, Error>
pub fn nested(&mut self) -> Result<TxnRw<'_>, Error>
Start nested transaction
Panics if environment does not support nested transactions (which is
the case when the EnvBuilder::writemap
flag has been set).
sourcepub fn put<'kr, 'vr, K, V, C, KRef, VRef>(
&mut self,
db: &Db<K, V, C>,
key: KRef,
value: VRef
) -> Result<(), Error> where
K: ?Sized + Storable + 'kr,
V: ?Sized + Storable + 'vr,
C: Constraint,
KRef: StorableRef<'kr, K>,
VRef: StorableRef<'vr, V>,
pub fn put<'kr, 'vr, K, V, C, KRef, VRef>(
&mut self,
db: &Db<K, V, C>,
key: KRef,
value: VRef
) -> Result<(), Error> where
K: ?Sized + Storable + 'kr,
V: ?Sized + Storable + 'vr,
C: Constraint,
KRef: StorableRef<'kr, K>,
VRef: StorableRef<'vr, V>,
Put value into database
This will overwrite an existing value if the database does not use the
DbOptions::keys_duplicate
option.
sourcepub fn put_unless_key_exists<'kr, 'vr, K, V, C, KRef, VRef>(
&mut self,
db: &Db<K, V, C>,
key: KRef,
value: VRef
) -> Result<bool, Error> where
K: ?Sized + Storable + 'kr,
V: ?Sized + Storable + 'vr,
C: Constraint,
KRef: StorableRef<'kr, K>,
VRef: StorableRef<'vr, V>,
pub fn put_unless_key_exists<'kr, 'vr, K, V, C, KRef, VRef>(
&mut self,
db: &Db<K, V, C>,
key: KRef,
value: VRef
) -> Result<bool, Error> where
K: ?Sized + Storable + 'kr,
V: ?Sized + Storable + 'vr,
C: Constraint,
KRef: StorableRef<'kr, K>,
VRef: StorableRef<'vr, V>,
Put value into database unless key exists
Returns Ok(false)
if key exists.
sourcepub fn put_unless_pair_exists<'kr, 'vr, K, V, KRef, VRef>(
&mut self,
db: &Db<K, V, KeysDuplicate>,
key: KRef,
value: VRef
) -> Result<bool, Error> where
K: ?Sized + Storable + 'kr,
V: ?Sized + Storable + 'vr,
KRef: StorableRef<'kr, K>,
VRef: StorableRef<'vr, V>,
pub fn put_unless_pair_exists<'kr, 'vr, K, V, KRef, VRef>(
&mut self,
db: &Db<K, V, KeysDuplicate>,
key: KRef,
value: VRef
) -> Result<bool, Error> where
K: ?Sized + Storable + 'kr,
V: ?Sized + Storable + 'vr,
KRef: StorableRef<'kr, K>,
VRef: StorableRef<'vr, V>,
Put value into database unless key-value pair exists
Returns Ok(false)
if key-value pair exists.
sourcepub fn delete_key<'kr, K, V, C, KRef>(
&mut self,
db: &Db<K, V, C>,
key: KRef
) -> Result<bool, Error> where
K: ?Sized + Storable + 'kr,
V: ?Sized + Storable,
C: Constraint,
KRef: StorableRef<'kr, K>,
pub fn delete_key<'kr, K, V, C, KRef>(
&mut self,
db: &Db<K, V, C>,
key: KRef
) -> Result<bool, Error> where
K: ?Sized + Storable + 'kr,
V: ?Sized + Storable,
C: Constraint,
KRef: StorableRef<'kr, K>,
Delete all values from database that match a given key
sourcepub fn delete_pair<'kr, 'vr, K, V, KRef, VRef>(
&mut self,
db: &Db<K, V, KeysDuplicate>,
key: KRef,
value: VRef
) -> Result<bool, Error> where
K: ?Sized + Storable + 'kr,
V: ?Sized + Storable + 'vr,
KRef: StorableRef<'kr, K>,
VRef: StorableRef<'vr, V>,
pub fn delete_pair<'kr, 'vr, K, V, KRef, VRef>(
&mut self,
db: &Db<K, V, KeysDuplicate>,
key: KRef,
value: VRef
) -> Result<bool, Error> where
K: ?Sized + Storable + 'kr,
V: ?Sized + Storable + 'vr,
KRef: StorableRef<'kr, K>,
VRef: StorableRef<'vr, V>,
Delete key-value pair from database
Trait Implementations
sourceimpl<'a> Txn for TxnRw<'a>
impl<'a> Txn for TxnRw<'a>
sourcefn get<'kr, K, V, C, KRef>(
&self,
db: &Db<K, V, C>,
key: KRef
) -> Result<Option<V::AlignedRef<'_>>, Error> where
K: ?Sized + Storable + 'kr,
V: ?Sized + Storable,
C: Constraint,
KRef: StorableRef<'kr, K>,
fn get<'kr, K, V, C, KRef>(
&self,
db: &Db<K, V, C>,
key: KRef
) -> Result<Option<V::AlignedRef<'_>>, Error> where
K: ?Sized + Storable + 'kr,
V: ?Sized + Storable,
C: Constraint,
KRef: StorableRef<'kr, K>,
Get reference to value in database
sourcefn new_cursor<K, V, C>(
&self,
db: &Db<K, V, C>
) -> Result<Cursor<K, V, C>, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
C: Constraint,
fn new_cursor<K, V, C>(
&self,
db: &Db<K, V, C>
) -> Result<Cursor<K, V, C>, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
C: Constraint,
Create a new cursor
sourcefn cursor_get_current_value_count<K, V>(
&self,
cursor: &Cursor<K, V, KeysDuplicate>
) -> Result<usize, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
fn cursor_get_current_value_count<K, V>(
&self,
cursor: &Cursor<K, V, KeysDuplicate>
) -> Result<usize, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
Get number of values for current cursor position
sourcefn cursor_set_first<K, V, C>(
&self,
cursor: &Cursor<K, V, C>
) -> Result<bool, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
C: Constraint,
fn cursor_set_first<K, V, C>(
&self,
cursor: &Cursor<K, V, C>
) -> Result<bool, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
C: Constraint,
Set cursor to first entry in database
sourcefn cursor_set_first_get_pair<K, V, C>(
&self,
cursor: &Cursor<K, V, C>
) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>, Error> 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<'_>)>, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
C: Constraint,
Set cursor to first entry in database and get pair
sourcefn cursor_set_last<K, V, C>(
&self,
cursor: &Cursor<K, V, C>
) -> Result<bool, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
C: Constraint,
fn cursor_set_last<K, V, C>(
&self,
cursor: &Cursor<K, V, C>
) -> Result<bool, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
C: Constraint,
Set cursor to last entry in database
sourcefn cursor_set_last_get_pair<K, V, C>(
&self,
cursor: &Cursor<K, V, C>
) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>, Error> 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<'_>)>, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
C: Constraint,
Set cursor to last entry in database and get pair
sourcefn cursor_get_current_key<K, V, C>(
&self,
cursor: &Cursor<K, V, C>
) -> Result<Option<K::AlignedRef<'_>>, Error> 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<'_>>, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
C: Constraint,
Get key at current cursor position
sourcefn cursor_get_current_value<K, V, C>(
&self,
cursor: &Cursor<K, V, C>
) -> Result<Option<V::AlignedRef<'_>>, Error> 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<'_>>, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
C: Constraint,
Get value at current cursor position
sourcefn cursor_get_current_pair<K, V, C>(
&self,
cursor: &Cursor<K, V, C>
) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>, Error> 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<'_>)>, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
C: Constraint,
Get key-value pair at current cursor position
sourcefn cursor_set_key<'kr, K, V, C, KRef>(
&self,
cursor: &Cursor<K, V, C>,
key: KRef
) -> Result<bool, Error> where
K: ?Sized + Storable + 'kr,
V: ?Sized + Storable,
C: Constraint,
KRef: StorableRef<'kr, K>,
fn cursor_set_key<'kr, K, V, C, KRef>(
&self,
cursor: &Cursor<K, V, C>,
key: KRef
) -> Result<bool, Error> where
K: ?Sized + Storable + 'kr,
V: ?Sized + Storable,
C: Constraint,
KRef: StorableRef<'kr, K>,
Set cursor to key
sourcefn cursor_set_key_get_value<'kr, K, V, C, KRef>(
&self,
cursor: &Cursor<K, V, C>,
key: KRef
) -> Result<Option<V::AlignedRef<'_>>, Error> 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<'_>>, Error> where
K: ?Sized + Storable + 'kr,
V: ?Sized + Storable,
C: Constraint,
KRef: StorableRef<'kr, K>,
Set cursor to key and get value
sourcefn cursor_search_key_get_pair<'kr, K, V, C, KRef>(
&self,
cursor: &Cursor<K, V, C>,
key: KRef
) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>, Error> 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<'_>)>, Error> 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
sourcefn cursor_set_next_get_pair<K, V, C>(
&self,
cursor: &Cursor<K, V, C>
) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>, Error> 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<'_>)>, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
C: Constraint,
Move cursor to next entry in database and get pair
sourcefn cursor_set_prev_get_pair<K, V, C>(
&self,
cursor: &Cursor<K, V, C>
) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>, Error> 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<'_>)>, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
C: Constraint,
Move cursor to previous entry in database and get pair
sourcefn cursor_set_next_key_get_pair<K, V, C>(
&self,
cursor: &Cursor<K, V, C>
) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>, Error> 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<'_>)>, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
C: Constraint,
Move cursor to first value of next key and get pair
sourcefn cursor_set_prev_key_get_pair<K, V, C>(
&self,
cursor: &Cursor<K, V, C>
) -> Result<Option<(K::AlignedRef<'_>, V::AlignedRef<'_>)>, Error> 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<'_>)>, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
C: Constraint,
Move cursor to last value of previous key and get pair
sourcefn cursor_set_first_value<K, V>(
&self,
cursor: &Cursor<K, V, KeysDuplicate>
) -> Result<bool, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
fn cursor_set_first_value<K, V>(
&self,
cursor: &Cursor<K, V, KeysDuplicate>
) -> Result<bool, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
Move cursor to first value of current key
sourcefn cursor_set_first_value_get_value<K, V>(
&self,
cursor: &Cursor<K, V, KeysDuplicate>
) -> Result<Option<V::AlignedRef<'_>>, Error> 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<'_>>, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
Move cursor to first value of current key and get value
sourcefn cursor_set_last_value<K, V>(
&self,
cursor: &Cursor<K, V, KeysDuplicate>
) -> Result<bool, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
fn cursor_set_last_value<K, V>(
&self,
cursor: &Cursor<K, V, KeysDuplicate>
) -> Result<bool, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
Move cursor to last value of current key
sourcefn cursor_set_last_value_get_value<K, V>(
&self,
cursor: &Cursor<K, V, KeysDuplicate>
) -> Result<Option<V::AlignedRef<'_>>, Error> 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<'_>>, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
Move cursor to last value of current key and get value
sourcefn cursor_set_pair<'kr, 'vr, K, V, KRef, VRef>(
&self,
cursor: &Cursor<K, V, KeysDuplicate>,
key: KRef,
value: VRef
) -> Result<bool, Error> where
K: ?Sized + Storable + 'kr,
V: ?Sized + Storable + 'vr,
KRef: StorableRef<'kr, K>,
VRef: StorableRef<'vr, V>,
fn cursor_set_pair<'kr, 'vr, K, V, KRef, VRef>(
&self,
cursor: &Cursor<K, V, KeysDuplicate>,
key: KRef,
value: VRef
) -> Result<bool, Error> where
K: ?Sized + Storable + 'kr,
V: ?Sized + Storable + 'vr,
KRef: StorableRef<'kr, K>,
VRef: StorableRef<'vr, V>,
Set cursor to key-value pair
sourcefn 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<'_>>, Error> 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<'_>>, Error> 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
sourcefn cursor_set_next_value_get_value<K, V>(
&self,
cursor: &Cursor<K, V, KeysDuplicate>
) -> Result<Option<V::AlignedRef<'_>>, Error> 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<'_>>, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
Move cursor to next value of current key and get value
sourcefn cursor_set_prev_value_get_value<K, V>(
&self,
cursor: &Cursor<K, V, KeysDuplicate>
) -> Result<Option<V::AlignedRef<'_>>, Error> 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<'_>>, Error> where
K: ?Sized + Storable,
V: ?Sized + Storable,
Move cursor to next value of current key and get value
Auto Trait Implementations
impl<'a> !RefUnwindSafe for TxnRw<'a>
impl<'a> !Send for TxnRw<'a>
impl<'a> !Sync for TxnRw<'a>
impl<'a> Unpin for TxnRw<'a>
impl<'a> !UnwindSafe for TxnRw<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more