pub struct StateStore { /* private fields */ }Expand description
State store for multiple params
Implementations§
Source§impl StateStore
impl StateStore
Sourcepub fn with_config(config: StateStoreConfig) -> Self
pub fn with_config(config: StateStoreConfig) -> Self
Create a new state store with the specified config
Sourcepub fn config(&self) -> &StateStoreConfig
pub fn config(&self) -> &StateStoreConfig
Get the current configuration
Sourcepub fn get(&self, address: &str) -> Option<&ParamState>
pub fn get(&self, address: &str) -> Option<&ParamState>
Get a param’s current state (does not update last_accessed)
Sourcepub fn get_mut(&mut self, address: &str) -> Option<&mut ParamState>
pub fn get_mut(&mut self, address: &str) -> Option<&mut ParamState>
Get a param’s current state and update last_accessed
Sourcepub fn get_value(&self, address: &str) -> Option<&Value>
pub fn get_value(&self, address: &str) -> Option<&Value>
Get a param’s current value (does not update last_accessed)
Sourcepub fn get_value_mut(&mut self, address: &str) -> Option<&Value>
pub fn get_value_mut(&mut self, address: &str) -> Option<&Value>
Get a param’s current value and update last_accessed
Sourcepub fn set(
&mut self,
address: &str,
value: Value,
writer: &str,
revision: Option<u64>,
lock: bool,
unlock: bool,
) -> Result<u64, UpdateError>
pub fn set( &mut self, address: &str, value: Value, writer: &str, revision: Option<u64>, lock: bool, unlock: bool, ) -> Result<u64, UpdateError>
Set a param value, creating if necessary
Sourcepub fn cleanup_stale(&mut self, ttl: Duration) -> usize
pub fn cleanup_stale(&mut self, ttl: Duration) -> usize
Remove params that haven’t been accessed within the TTL Returns the number of params removed
Sourcepub fn cleanup_stale_with_config(&mut self) -> usize
pub fn cleanup_stale_with_config(&mut self) -> usize
Run cleanup using the configured TTL (if any) Returns the number of params removed
Sourcepub fn get_matching(&self, pattern: &str) -> Vec<(&str, &ParamState)>
pub fn get_matching(&self, pattern: &str) -> Vec<(&str, &ParamState)>
Get all params matching a pattern
Sourcepub fn snapshot(&self) -> Vec<(&str, &ParamState)>
pub fn snapshot(&self) -> Vec<(&str, &ParamState)>
Get all params as a snapshot
Sourcepub fn remove(&mut self, address: &str) -> Option<ParamState>
pub fn remove(&mut self, address: &str) -> Option<ParamState>
Remove a param
Trait Implementations§
Source§impl Debug for StateStore
impl Debug for StateStore
Auto Trait Implementations§
impl Freeze for StateStore
impl RefUnwindSafe for StateStore
impl Send for StateStore
impl Sync for StateStore
impl Unpin for StateStore
impl UnsafeUnpin for StateStore
impl UnwindSafe for StateStore
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