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>
impl<'a, M: Mutability, D> Transaction<'a, M, D>
sourcepub fn get<K: 'static + ?Sized>(
&self,
key: &K
) -> Result<Option<<<D as ArchiveType<K>>::Value as DataLoad<'_>>::OutputType>, ArchiveError>where
D: ArchiveType<K>,
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.
sourcepub fn keys<K: 'static + ?Sized>(
&self
) -> impl '_ + Iterator<Item = Result<<<D as ArchiveType<K>>::Key as BinaryConverter<'_>>::ValueOutput, ArchiveError>>where
D: ArchiveType<K>,
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.
sourcepub fn values<K: 'static + ?Sized>(
&self
) -> impl '_ + Iterator<Item = Result<<<D as ArchiveType<K>>::Value as DataLoad<'_>>::OutputType, ArchiveError>>where
D: ArchiveType<K>,
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.
sourcepub 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>,
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>
impl<'a, D> Transaction<'a, Mut, D>
sourcepub fn commit(self) -> Result<(), ArchiveError>
pub fn commit(self) -> Result<(), ArchiveError>
Commits this transaction to the archive. Any modifications will become visible for subsequent reads and writes.
sourcepub 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>>,
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.
sourcepub 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>>,
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).
sourcepub fn remove<K: 'static + ?Sized>(
&mut self,
key: &K
) -> Result<Option<<<D as ArchiveType<K>>::Value as DataLoad<'_>>::OutputType>, ArchiveError>where
D: ArchiveType<K>,
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>
impl<'a, M: Mutability, D> Debug for Transaction<'a, M, D>
source§impl<'a, M: Mutability, D> Drop for Transaction<'a, M, D>
impl<'a, M: Mutability, D> Drop for Transaction<'a, M, D>
impl<'a, M: Mutability, D> Send for Transaction<'a, M, D>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more