pub struct TransactionStorage<S> { /* private fields */ }Expand description
Wrapper around a state storage that provides transactional semantics.
Implementations§
Source§impl<S> TransactionStorage<S>
impl<S> TransactionStorage<S>
Sourcepub fn new(storage: S) -> Self
pub fn new(storage: S) -> Self
Create a new transaction storage around the given state storage.
Sourcepub fn view(&self) -> TransactionView<S>where
S: Clone,
pub fn view(&self) -> TransactionView<S>where
S: Clone,
Create a view of this transaction.
Sourcepub async fn commit(&mut self) -> Result<()>where
S: StateStorage,
pub async fn commit(&mut self) -> Result<()>where
S: StateStorage,
Commit the transaction.
Sourcepub fn into_updates(self) -> impl Iterator<Item = (ContentAddress, Key, Value)>
pub fn into_updates(self) -> impl Iterator<Item = (ContentAddress, Key, Value)>
Extract the updates from this transaction.
Sourcepub async fn update_state(
&mut self,
address: &ContentAddress,
key: Key,
value: Vec<Word>,
) -> Result<Vec<Word>>where
S: QueryState,
pub async fn update_state(
&mut self,
address: &ContentAddress,
key: Key,
value: Vec<Word>,
) -> Result<Vec<Word>>where
S: QueryState,
Update the state of this transaction.
Sourcepub fn apply_state(
&mut self,
address: &ContentAddress,
key: Key,
value: Vec<Word>,
)
pub fn apply_state( &mut self, address: &ContentAddress, key: Key, value: Vec<Word>, )
Apply state changes without returning the previous value.
Sourcepub async fn query_state(
&self,
address: &ContentAddress,
key: &Key,
) -> Result<Vec<Word>>where
S: QueryState,
pub async fn query_state(
&self,
address: &ContentAddress,
key: &Key,
) -> Result<Vec<Word>>where
S: QueryState,
Query the state of this transaction.
Trait Implementations§
Source§impl<S: Clone> Clone for TransactionStorage<S>
impl<S: Clone> Clone for TransactionStorage<S>
Source§fn clone(&self) -> TransactionStorage<S>
fn clone(&self) -> TransactionStorage<S>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<S> Freeze for TransactionStorage<S>where
S: Freeze,
impl<S> RefUnwindSafe for TransactionStorage<S>where
S: RefUnwindSafe,
impl<S> Send for TransactionStorage<S>where
S: Send,
impl<S> Sync for TransactionStorage<S>where
S: Sync,
impl<S> Unpin for TransactionStorage<S>where
S: Unpin,
impl<S> UnwindSafe for TransactionStorage<S>where
S: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more