Struct roach::Transaction

source ·
pub struct Transaction<'a, M: Mutability, D> { /* private fields */ }
Expand description

Facilitates an atomic interaction with an Archive.

Implementations§

source§

impl<'a, M: Mutability, D> Transaction<'a, M, D>

source

pub fn get<K: 'static + ?Sized>( &self, key: &K ) -> Result<Option<<<D as ArchiveType<K>>::Value as DataLoad<'_>>::OutputType>, ArchiveError>where D: ArchiveType<K>,

Gets the value with the specified key from the archive, if any.

source

pub fn keys<K: 'static + ?Sized>( &self ) -> impl '_ + Iterator<Item = Result<<<D as ArchiveType<K>>::Key as BinaryConverter<'_>>::ValueOutput, ArchiveError>>where D: ArchiveType<K>,

Obtains an iterator over all keys of the given type in the archive.

source

pub fn values<K: 'static + ?Sized>( &self ) -> impl '_ + Iterator<Item = Result<<<D as ArchiveType<K>>::Value as DataLoad<'_>>::OutputType, ArchiveError>>where D: ArchiveType<K>,

Obtains an iterator over all values for the provided key type in the archive.

source

pub fn iter<K: 'static + ?Sized>( &self ) -> impl '_ + Iterator<Item = Result<(<<D as ArchiveType<K>>::Key as BinaryConverter<'_>>::ValueOutput, <<D as ArchiveType<K>>::Value as DataLoad<'_>>::OutputType), ArchiveError>>where D: ArchiveType<K>,

Obtains an iterator over all keys and values of the given type in the archive.

source§

impl<'a, D> Transaction<'a, Mut, D>

source

pub fn commit(self) -> Result<(), ArchiveError>

Commits this transaction to the archive. Any modifications will become visible for subsequent reads and writes.

source

pub fn set<'b, K: 'static + ?Sized, V: 'b + ?Sized>( &'b mut self, key: &K, value: &V ) -> Result<(), ArchiveError>where D: ArchiveType<K>, <D as ArchiveType<K>>::Value: BinaryConverter<'b, Target = V>, <<<<D as ArchiveType<K>>::Value as BinaryConverter<'b>>::ByteOutput as IntoBytes>::RefType as RedbValue>::SelfType<'b>: Borrow<<<<D as ArchiveType<K>>::Value as DataLoad<'b>>::RawValueType as RedbValue>::SelfType<'b>>,

Sets the provided key to the given value in the archive.

source

pub fn replace<'b, K: 'static + ?Sized, V: 'b + ?Sized>( &'b mut self, key: &K, value: &V ) -> Result<Option<<<D as ArchiveType<K>>::Value as DataLoad<'_>>::OutputType>, ArchiveError>where D: ArchiveType<K>, <D as ArchiveType<K>>::Value: BinaryConverter<'b, Target = V>, <<<<D as ArchiveType<K>>::Value as BinaryConverter<'b>>::ByteOutput as IntoBytes>::RefType as RedbValue>::SelfType<'b>: Borrow<<<<D as ArchiveType<K>>::Value as DataLoad<'b>>::RawValueType as RedbValue>::SelfType<'b>>,

Replaces the value of the provided key, returning the old value (if any).

source

pub fn remove<K: 'static + ?Sized>( &mut self, key: &K ) -> Result<Option<<<D as ArchiveType<K>>::Value as DataLoad<'_>>::OutputType>, ArchiveError>where D: ArchiveType<K>,

Removes the value with the specified key from the archive.

Trait Implementations§

source§

impl<'a, M: Mutability, D> Debug for Transaction<'a, M, D>

source§

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

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

impl<'a, M: Mutability, D> Drop for Transaction<'a, M, D>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<'a, M: Mutability, D> Send for Transaction<'a, M, D>

source§

impl<'a, M: Mutability, D> Sync for Transaction<'a, M, D>

Auto Trait Implementations§

§

impl<'a, M, D> !RefUnwindSafe for Transaction<'a, M, D>

§

impl<'a, M, D> Unpin for Transaction<'a, M, D>where D: Unpin, <M as MutabilityInner>::TableType<'static, 'static, (), ()>: Unpin,

§

impl<'a, M, D> UnwindSafe for Transaction<'a, M, D>where D: UnwindSafe, <M as MutabilityInner>::TableType<'static, 'static, (), ()>: UnwindSafe, <M as MutabilityInner>::TransactionType<'a>: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.