pub struct Snapshot {
pub tokens: HashMap<String, i64>,
pub data: HashMap<String, Value>,
}Expand description
The current state of all states in a schema.
Fields§
§tokens: HashMap<String, i64>§data: HashMap<String, Value>Implementations§
Source§impl Snapshot
impl Snapshot
pub fn new() -> Self
Sourcepub fn from_schema(s: &Schema) -> Self
pub fn from_schema(s: &Schema) -> Self
Creates a snapshot initialized from schema defaults.
pub fn get_tokens(&self, state_id: &str) -> i64
pub fn set_tokens(&mut self, state_id: &str, count: i64)
pub fn add_tokens(&mut self, state_id: &str, delta: i64)
pub fn get_data(&self, state_id: &str) -> Option<&Value>
pub fn set_data(&mut self, state_id: &str, value: Value)
Sourcepub fn get_data_map(&self, state_id: &str) -> Option<&Map<String, Value>>
pub fn get_data_map(&self, state_id: &str) -> Option<&Map<String, Value>>
Returns data as a mutable JSON object, or None.
Sourcepub fn get_data_map_value(&self, state_id: &str, key: &str) -> Option<&Value>
pub fn get_data_map_value(&self, state_id: &str, key: &str) -> Option<&Value>
Gets a value from a data state map.
Sourcepub fn set_data_map_value(&mut self, state_id: &str, key: &str, value: Value)
pub fn set_data_map_value(&mut self, state_id: &str, key: &str, value: Value)
Sets a value in a data state map.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Snapshot
impl<'de> Deserialize<'de> for Snapshot
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Snapshot
impl RefUnwindSafe for Snapshot
impl Send for Snapshot
impl Sync for Snapshot
impl Unpin for Snapshot
impl UnsafeUnpin for Snapshot
impl UnwindSafe for Snapshot
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