Transaction

Struct Transaction 

Source
pub struct Transaction { /* private fields */ }
Expand description

A serializable snapshot isolated database transaction

Implementations§

Source§

impl Transaction

Source

pub fn closed(&self) -> bool

Check if the transaction is closed

Source

pub async fn cancel(&mut self) -> Result<(), Error>

Cancel the transaction and rollback any changes

Source

pub async fn commit(&mut self) -> Result<(), Error>

Commit the transaction and store all changes

Source

pub async fn exists(&self, key: Key) -> Result<bool, Error>

Check if a key exists in the database

Source

pub async fn get(&self, key: Key) -> Result<Option<Val>, Error>

Fetch a key from the database

Source

pub async fn set(&mut self, key: Key, val: Val) -> Result<(), Error>

Insert or update a key in the database

Source

pub async fn put(&mut self, key: Key, val: Val) -> Result<(), Error>

Insert a key if it doesn’t exist in the database

Source

pub async fn putc( &mut self, key: Key, val: Val, chk: Option<Val>, ) -> Result<(), Error>

Insert a key if it matches a value

Source

pub async fn del(&mut self, key: Key) -> Result<(), Error>

Delete a key from the database

Source

pub async fn delc(&mut self, key: Key, chk: Option<Val>) -> Result<(), Error>

Delete a key if it matches a value

Source

pub async fn keys(&self, rng: Range<Key>, limit: u32) -> Result<Vec<Key>, Error>

Retrieve a range of keys from the databases

Source

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

Source

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

Source

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

Source

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

Source

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.