pub struct StateDelta<S: StateRead> { /* private fields */ }
Expand description
An arbitrarily-deeply nested stack of delta updates to an underlying state.
This API allows exploring a tree of possible execution paths concurrently, before finally selecting one and applying it to the underlying state.
Using this API requires understanding its invariants.
On creation, StateDelta::new
takes ownership of a StateRead + StateWrite
instance, acquiring a “write lock” over the underlying state (since &mut S
is StateWrite
if S: StateWrite
, it’s possible to pass a unique
reference).
The resulting StateDelta
instance is a “leaf” state, and can be used for
reads and writes, following the some execution path.
When two potential execution paths diverge, delta.fork()
can be used to
fork the state update. The new forked StateDelta
will include all
previous state writes made to the original (and its ancestors). Any writes
made to the original StateDelta
after fork()
is called will not be seen
by the forked state.
Finally, after some execution path has been selected, calling
delta.apply()
on one of the possible state updates will commit the changes
to the underlying state instance, and invalidate all other delta updates in
the same family. It is a programming error to use the other delta updates
after apply()
has been called, but ideally this should not be a problem in
practice: the API is intended to explore a tree of possible execution paths;
once one has been selected, the others should be discarded.
Implementations§
Source§impl<S: StateRead> StateDelta<S>
impl<S: StateRead> StateDelta<S>
Source§impl<S: StateRead + StateWrite> StateDelta<S>
impl<S: StateRead + StateWrite> StateDelta<S>
Trait Implementations§
Source§impl<S: StateRead> StateRead for StateDelta<S>
impl<S: StateRead> StateRead for StateDelta<S>
type GetRawFut = CacheFuture<<S as StateRead>::GetRawFut>
type PrefixRawStream = StateDeltaPrefixRawStream<<S as StateRead>::PrefixRawStream>
type PrefixKeysStream = StateDeltaPrefixKeysStream<<S as StateRead>::PrefixKeysStream>
type NonconsensusPrefixRawStream = StateDeltaNonconsensusPrefixRawStream<<S as StateRead>::NonconsensusPrefixRawStream>
type NonconsensusRangeRawStream = StateDeltaNonconsensusRangeRawStream<<S as StateRead>::NonconsensusRangeRawStream>
Source§fn get_raw(&self, key: &str) -> Self::GetRawFut
fn get_raw(&self, key: &str) -> Self::GetRawFut
Source§fn nonverifiable_get_raw(&self, key: &[u8]) -> Self::GetRawFut
fn nonverifiable_get_raw(&self, key: &[u8]) -> Self::GetRawFut
Source§fn object_type(&self, key: &'static str) -> Option<TypeId>
fn object_type(&self, key: &'static str) -> Option<TypeId>
TypeId
] of the object stored at key
in the ephemeral key-object store, if any
is present.Source§fn object_get<T: Any + Send + Sync + Clone>(
&self,
key: &'static str,
) -> Option<T>
fn object_get<T: Any + Send + Sync + Clone>( &self, key: &'static str, ) -> Option<T>
Source§fn prefix_raw(&self, prefix: &str) -> Self::PrefixRawStream
fn prefix_raw(&self, prefix: &str) -> Self::PrefixRawStream
Source§fn prefix_keys(&self, prefix: &str) -> Self::PrefixKeysStream
fn prefix_keys(&self, prefix: &str) -> Self::PrefixKeysStream
Source§fn nonverifiable_prefix_raw(
&self,
prefix: &[u8],
) -> Self::NonconsensusPrefixRawStream
fn nonverifiable_prefix_raw( &self, prefix: &[u8], ) -> Self::NonconsensusPrefixRawStream
Source§fn nonverifiable_range_raw(
&self,
prefix: Option<&[u8]>,
range: impl RangeBounds<Vec<u8>>,
) -> Result<Self::NonconsensusRangeRawStream>
fn nonverifiable_range_raw( &self, prefix: Option<&[u8]>, range: impl RangeBounds<Vec<u8>>, ) -> Result<Self::NonconsensusRangeRawStream>
Source§impl<S: StateRead> StateWrite for StateDelta<S>
impl<S: StateRead> StateWrite for StateDelta<S>
Source§fn put_raw(&mut self, key: String, value: OwnedValue)
fn put_raw(&mut self, key: String, value: OwnedValue)
Source§fn nonverifiable_delete(&mut self, key: Vec<u8>)
fn nonverifiable_delete(&mut self, key: Vec<u8>)
Source§fn nonverifiable_put_raw(&mut self, key: Vec<u8>, value: Vec<u8>)
fn nonverifiable_put_raw(&mut self, key: Vec<u8>, value: Vec<u8>)
Source§fn object_put<T: Clone + Any + Send + Sync>(
&mut self,
key: &'static str,
value: T,
)
fn object_put<T: Clone + Any + Send + Sync>( &mut self, key: &'static str, value: T, )
Source§fn object_delete(&mut self, key: &'static str)
fn object_delete(&mut self, key: &'static str)
Auto Trait Implementations§
impl<S> Freeze for StateDelta<S>
impl<S> !RefUnwindSafe for StateDelta<S>
impl<S> Send for StateDelta<S>
impl<S> Sync for StateDelta<S>
impl<S> Unpin for StateDelta<S>
impl<S> !UnwindSafe for StateDelta<S>
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request