pub struct SharedMovingAverageStore(pub Arc<InMemoryStateStore<MovingAverageState>>);Expand description
Wrapper struct to implement StateStore on Arc<InMemoryStateStore<MovingAverageState>>
Tuple Fields§
§0: Arc<InMemoryStateStore<MovingAverageState>>Trait Implementations§
Source§fn get(&self) -> StateResult<Option<MovingAverageState>>
fn get(&self) -> StateResult<Option<MovingAverageState>>
Get a read-only reference to the current state. Read more
Source§fn set(&self, state: MovingAverageState) -> StateResult<()>
fn set(&self, state: MovingAverageState) -> StateResult<()>
Set the state to a new value.
Source§fn update_with(
&self,
f: Box<dyn FnOnce(Option<MovingAverageState>) -> MovingAverageState + Send>,
) -> StateResult<MovingAverageState>
fn update_with( &self, f: Box<dyn FnOnce(Option<MovingAverageState>) -> MovingAverageState + Send>, ) -> StateResult<MovingAverageState>
Update the state using a boxed function. Read more
Source§fn reset(&self) -> StateResult<()>
fn reset(&self) -> StateResult<()>
Reset the state to its initial value or clear it.
Source§fn is_initialized(&self) -> bool
fn is_initialized(&self) -> bool
Check if the state has been initialized.
Source§fn initial_state(&self) -> Option<MovingAverageState>
fn initial_state(&self) -> Option<MovingAverageState>
Get the initial state value if one was provided.
Auto Trait Implementations§
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<S, T> CheckpointableStateStore<S> for T
impl<S, T> CheckpointableStateStore<S> for T
Source§fn create_json_checkpoint(&self) -> Result<Vec<u8>, CheckpointError>
fn create_json_checkpoint(&self) -> Result<Vec<u8>, CheckpointError>
Create a JSON checkpoint of the current state.
Source§fn restore_from_json_checkpoint(
&self,
data: &[u8],
) -> Result<(), CheckpointError>
fn restore_from_json_checkpoint( &self, data: &[u8], ) -> Result<(), CheckpointError>
Restore state from a JSON checkpoint.
Source§fn create_json_checkpoint_pretty(&self) -> Result<Vec<u8>, CheckpointError>
fn create_json_checkpoint_pretty(&self) -> Result<Vec<u8>, CheckpointError>
Create a pretty-printed JSON checkpoint of the current state.
Source§fn save_checkpoint(
&self,
checkpoint_store: &dyn CheckpointStore,
) -> Result<(), CheckpointError>
fn save_checkpoint( &self, checkpoint_store: &dyn CheckpointStore, ) -> Result<(), CheckpointError>
Save the current state to a checkpoint store.
Source§fn load_checkpoint(
&self,
checkpoint_store: &dyn CheckpointStore,
) -> Result<bool, CheckpointError>
fn load_checkpoint( &self, checkpoint_store: &dyn CheckpointStore, ) -> Result<bool, CheckpointError>
Load state from a checkpoint store.
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S, T> StateCheckpoint<S> for T
impl<S, T> StateCheckpoint<S> for T
Source§fn serialize_state(&self) -> Result<Vec<u8>, StateError>
fn serialize_state(&self) -> Result<Vec<u8>, StateError>
Serialize the current state to a byte vector. Read more
Source§fn deserialize_and_set_state(&self, data: &[u8]) -> Result<(), StateError>
fn deserialize_and_set_state(&self, data: &[u8]) -> Result<(), StateError>
Deserialize state from a byte vector and set it. Read more