pub struct RunState {
snapshot: StateSnapshot,
}Fields§
§snapshot: StateSnapshotImplementations§
Source§impl RunState
impl RunState
pub fn new() -> Self
Sourcepub fn from_snapshot(snapshot: StateSnapshot) -> Self
pub fn from_snapshot(snapshot: StateSnapshot) -> Self
A state restored from a checkpoint. The bits come back exactly as saved.
pub fn snapshot(&self) -> StateSnapshot
pub fn reducer_of(&self, name: &str) -> Reducer
pub fn get(&self, name: &str) -> Option<&Tv>
Sourcepub fn declare(
&mut self,
name: &str,
reducer: Reducer,
) -> Result<(), StateError>
pub fn declare( &mut self, name: &str, reducer: Reducer, ) -> Result<(), StateError>
Declare how name’s writes combine. Declaring the same reducer again is
fine. Once the name has a value its reducer cannot change: another one is
a StateError::Type with needs “the reducer it was written under”.
A bad name is a StateError::Name. A declaration counts toward
STATE_CAP_BYTES like a value, because Self::size_bytes measures
the declarations too; one that would pass it is a
StateError::TooLarge and changes nothing.
Sourcepub fn write(&mut self, name: &str, value: Tv) -> Result<(), StateError>
pub fn write(&mut self, name: &str, value: Tv) -> Result<(), StateError>
Apply a write under the variable’s reducer (see the table above). On an
error nothing changes. After a write the state is at most STATE_CAP_BYTES.
Sourcepub fn size_bytes(&self) -> usize
pub fn size_bytes(&self) -> usize
The size of the state as JSON, the number STATE_CAP_BYTES bounds:
the length of serde_json::to_string(&snapshot()).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RunState
impl RefUnwindSafe for RunState
impl Send for RunState
impl Sync for RunState
impl Unpin for RunState
impl UnsafeUnpin for RunState
impl UnwindSafe for RunState
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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 more