Struct DBTransaction

Source
pub struct DBTransaction<D, T>
where D: 'static, T: 'static,
{ pub tx: Arc<Mutex<Option<T>>>, pub ok: bool, pub writable: bool, pub readable: bool, pub timestamp: i64, pub _db: Pin<Arc<D>>, }
Expand description

§Distributed Database Transaction

§Atomically reference counter

Shared references in Rust disallow mutation by default, and Arc is no exception: you cannot generally obtain a mutable reference to something inside an Arc. If you need to mutate through an Arc, use Mutex, RwLock, or one of the Atomic types.

because it tries to borrow arc as mutable. For it to happen, DerefMut would have to be implemented for Arc but it’s not because Arc is not meant to be mutable.

Fields§

§tx: Arc<Mutex<Option<T>>>§ok: bool§writable: bool§readable: bool§timestamp: i64§_db: Pin<Arc<D>>

Implementations§

Source§

impl<DBType, TxType> DBTransaction<DBType, TxType>
where DBType: 'static, TxType: 'static,

Source

pub fn new(tx: TxType, db: Pin<Arc<DBType>>, w: bool) -> Result<Self, Error>

Trait Implementations§

Source§

impl<D, T> Debug for DBTransaction<D, T>
where D: 'static + Debug, T: 'static + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl SimpleTransaction for DBTransaction<OptimisticTransactionDB, Transaction<'static, OptimisticTransactionDB>>

Source§

fn closed(&self) -> bool

Source§

fn count<'life0, 'async_trait>( &'life0 mut self, cf: CF, ) -> Pin<Box<dyn Future<Output = Result<usize, Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn cancel<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn commit<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn exi<'life0, 'async_trait, K>( &'life0 self, cf: CF, key: K, ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + 'async_trait>>
where K: Into<Vec<u8>> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Source§

fn get<'life0, 'async_trait, K>( &'life0 self, cf: CF, key: K, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Error>> + 'async_trait>>
where K: Into<Vec<u8>> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Fetch a key from the database
Source§

fn multi_get<'life0, 'async_trait, K>( &'life0 self, cf: CF, keys: Vec<K>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Option<Vec<u8>>>, Error>> + 'async_trait>>
where K: Into<Vec<u8>> + Send + AsRef<[u8]> + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Source§

fn set<'life0, 'async_trait, K, V>( &'life0 mut self, cf: CF, key: K, val: V, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>
where K: Into<Vec<u8>> + Send + 'async_trait, V: Into<Vec<u8>> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Insert or update a key in the database
Source§

fn put<'life0, 'async_trait, K, V>( &'life0 mut self, cf: CF, key: K, val: V, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>
where K: Into<Vec<u8>> + Send + 'async_trait, V: Into<Vec<u8>> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

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

fn del<'life0, 'async_trait, K>( &'life0 mut self, cf: CF, key: K, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>
where K: Into<Vec<u8>> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Delete a key
Source§

fn iterate<'life0, 'async_trait>( &'life0 self, cf: CF, ) -> Pin<Box<dyn Future<Output = Result<Vec<Result<(Vec<u8>, Vec<u8>), Error>>, Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn suffix_iterate<'life0, 'async_trait, S>( &'life0 self, cf: CF, suffix: S, ) -> Pin<Box<dyn Future<Output = Result<Vec<Result<(Vec<u8>, Vec<u8>), Error>>, Error>> + 'async_trait>>
where S: Into<Vec<u8>> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Source§

fn prefix_iterate<'life0, 'async_trait, P>( &'life0 self, cf: CF, prefix: P, ) -> Pin<Box<dyn Future<Output = Result<Vec<Result<(Vec<u8>, Vec<u8>), Error>>, Error>> + 'async_trait>>
where P: Into<Vec<u8>> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Source§

impl SimpleTransaction for DBTransaction<Database, WriteTransaction<'static>>

Source§

fn closed(&self) -> bool

Source§

fn count<'life0, 'async_trait>( &'life0 mut self, cf: CF, ) -> Pin<Box<dyn Future<Output = Result<usize, Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn cancel<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn commit<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn exi<'life0, 'async_trait, K>( &'life0 self, cf: CF, key: K, ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + 'async_trait>>
where K: Into<Vec<u8>> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Source§

fn get<'life0, 'async_trait, K>( &'life0 self, cf: CF, key: K, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Error>> + 'async_trait>>
where K: Into<Vec<u8>> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Fetch a key from the database
Source§

fn set<'life0, 'async_trait, K, V>( &'life0 mut self, cf: CF, key: K, val: V, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>
where K: Into<Vec<u8>> + Send + 'async_trait, V: Into<Vec<u8>> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Insert or update a key in the database
Source§

fn put<'life0, 'async_trait, K, V>( &'life0 mut self, cf: CF, key: K, val: V, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>
where K: Into<Vec<u8>> + Send + 'async_trait, V: Into<Vec<u8>> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

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

fn del<'life0, 'async_trait, K>( &'life0 mut self, cf: CF, key: K, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>
where K: Into<Vec<u8>> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Delete a key
Source§

fn iterate<'life0, 'async_trait>( &'life0 self, cf: CF, ) -> Pin<Box<dyn Future<Output = Result<Vec<Result<(Vec<u8>, Vec<u8>), Error>>, Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn prefix_iterate<'life0, 'async_trait, P>( &'life0 self, cf: CF, prefix: P, ) -> Pin<Box<dyn Future<Output = Result<Vec<Result<(Vec<u8>, Vec<u8>), Error>>, Error>> + 'async_trait>>
where P: Into<Vec<u8>> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Source§

fn suffix_iterate<'life0, 'async_trait, S>( &'life0 self, cf: CF, suffix: S, ) -> Pin<Box<dyn Future<Output = Result<Vec<Result<(Vec<u8>, Vec<u8>), Error>>, Error>> + 'async_trait>>
where S: Into<Vec<u8>> + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Source§

fn multi_get<'life0, 'async_trait, K>( &'life0 self, _cf: CF, _keys: Vec<K>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Option<Vec<u8>>>, Error>> + 'async_trait>>
where K: 'async_trait + Into<Vec<u8>> + Send + AsRef<[u8]>, Self: 'async_trait, 'life0: 'async_trait,

Auto Trait Implementations§

§

impl<D, T> Freeze for DBTransaction<D, T>

§

impl<D, T> !RefUnwindSafe for DBTransaction<D, T>

§

impl<D, T> Send for DBTransaction<D, T>
where D: Sync + Send, T: Send,

§

impl<D, T> Sync for DBTransaction<D, T>
where D: Sync + Send, T: Send,

§

impl<D, T> Unpin for DBTransaction<D, T>

§

impl<D, T> !UnwindSafe for DBTransaction<D, T>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V