Transaction

Struct Transaction 

Source
pub struct Transaction<K, V>
where K: Ord + Clone + Debug + Sync + Send + 'static, V: Eq + Clone + Debug + Sync + Send + 'static,
{ /* private fields */ }
Expand description

A serializable snapshot isolated database transaction

Implementations§

Source§

impl<K, V> Transaction<K, V>
where K: Ord + Clone + Debug + Sync + Send + 'static, V: Eq + Clone + Debug + Sync + Send + 'static,

Source

pub fn closed(&self) -> bool

Check if the transaction is closed

Source

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

Cancel the transaction and rollback any changes

Source

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

Commit the transaction and store all changes

Source

pub fn exists<Q>(&self, key: Q) -> Result<bool, Error>
where Q: Borrow<K>,

Check if a key exists in the database

Source

pub fn get<Q>(&self, key: Q) -> Result<Option<V>, Error>
where Q: Borrow<K>,

Fetch a key from the database

Source

pub fn set<Q>(&mut self, key: Q, val: V) -> Result<(), Error>
where Q: Into<K>,

Insert or update a key in the database

Source

pub fn put<Q>(&mut self, key: Q, val: V) -> Result<(), Error>
where Q: Borrow<K> + Into<K>,

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

Source

pub fn putc<Q>(&mut self, key: Q, val: V, chk: Option<V>) -> Result<(), Error>
where Q: Borrow<K> + Into<K>,

Insert a key if it matches a value

Source

pub fn del<Q>(&mut self, key: Q) -> Result<(), Error>
where Q: Borrow<K>,

Delete a key from the database

Source

pub fn delc<Q>(&mut self, key: Q, chk: Option<V>) -> Result<(), Error>
where Q: Borrow<K> + Into<K>,

Delete a key if it matches a value

Source

pub fn keys<Q>(&self, rng: Range<Q>, limit: usize) -> Result<Vec<K>, Error>
where Q: Into<K>,

Retrieve a range of keys from the databases

Source

pub fn scan<Q>(&self, rng: Range<Q>, limit: usize) -> Result<Vec<(K, V)>, Error>
where Q: Into<K>,

Retrieve a range of key-value pairs from the databases

Auto Trait Implementations§

§

impl<K, V> Freeze for Transaction<K, V>

§

impl<K, V> !RefUnwindSafe for Transaction<K, V>

§

impl<K, V> Send for Transaction<K, V>

§

impl<K, V> Sync for Transaction<K, V>

§

impl<K, V> Unpin for Transaction<K, V>
where K: Unpin, V: Unpin,

§

impl<K, V> !UnwindSafe for Transaction<K, V>

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.