pub struct Transaction { /* private fields */ }Expand description
A serializable snapshot isolated database transaction
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub async fn cancel(&mut self) -> Result<(), Error>
pub async fn cancel(&mut self) -> Result<(), Error>
Cancel the transaction and rollback any changes
Sourcepub async fn commit(&mut self) -> Result<(), Error>
pub async fn commit(&mut self) -> Result<(), Error>
Commit the transaction and store all changes
Sourcepub async fn exists(&self, key: Key) -> Result<bool, Error>
pub async fn exists(&self, key: Key) -> Result<bool, Error>
Check if a key exists in the database
Sourcepub async fn set(&mut self, key: Key, val: Val) -> Result<(), Error>
pub async fn set(&mut self, key: Key, val: Val) -> Result<(), Error>
Insert or update a key in the database
Sourcepub async fn put(&mut self, key: Key, val: Val) -> Result<(), Error>
pub async fn put(&mut self, key: Key, val: Val) -> Result<(), Error>
Insert a key if it doesn’t exist in the database
Sourcepub async fn putc(
&mut self,
key: Key,
val: Val,
chk: Option<Val>,
) -> Result<(), Error>
pub async fn putc( &mut self, key: Key, val: Val, chk: Option<Val>, ) -> Result<(), Error>
Insert a key if it matches a value
Sourcepub async fn delc(&mut self, key: Key, chk: Option<Val>) -> Result<(), Error>
pub async fn delc(&mut self, key: Key, chk: Option<Val>) -> Result<(), Error>
Delete a key if it matches a value
Sourcepub async fn keys(&self, rng: Range<Key>, limit: u32) -> Result<Vec<Key>, Error>
pub async fn keys(&self, rng: Range<Key>, limit: u32) -> Result<Vec<Key>, Error>
Retrieve a range of keys from the databases
Sourcepub async fn keysr(
&self,
rng: Range<Key>,
limit: u32,
) -> Result<Vec<Key>, Error>
pub async fn keysr( &self, rng: Range<Key>, limit: u32, ) -> Result<Vec<Key>, Error>
Retrieve a range of keys from the databases in reverse order
Sourcepub async fn scan(
&self,
rng: Range<Key>,
limit: u32,
) -> Result<Vec<(Key, Val)>, Error>
pub async fn scan( &self, rng: Range<Key>, limit: u32, ) -> Result<Vec<(Key, Val)>, Error>
Retrieve a range of key-value pairs from the databases
Sourcepub async fn scanr(
&self,
rng: Range<Key>,
limit: u32,
) -> Result<Vec<(Key, Val)>, Error>
pub async fn scanr( &self, rng: Range<Key>, limit: u32, ) -> Result<Vec<(Key, Val)>, Error>
Retrieve a range of key-value pairs from the databases in reverse order
Sourcepub async fn set_savepoint(&mut self) -> Result<(), Error>
pub async fn set_savepoint(&mut self) -> Result<(), Error>
Set a savepoint in the transaction for partial rollback
This method is stackable and can be called multiple times with
corresponding calls to rollback_to_savepoint
Sourcepub async fn rollback_to_savepoint(&mut self) -> Result<(), Error>
pub async fn rollback_to_savepoint(&mut self) -> Result<(), Error>
Rollback the transaction to the most recently set savepoint
After calling this method, subsequent modifications within this
transaction can be rolled back by calling rollback_to_savepoint
again if there are more savepoints in the stack