pub struct StoreState(/* private fields */);Expand description
Internal state of a store.
Implementations§
Source§impl StoreState
impl StoreState
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty StoreState.
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates an empty StoreState with at least the specified capacity.
Sourcepub fn into_inner(self) -> HashMap<String, Json>
pub fn into_inner(self) -> HashMap<String, Json>
Consumes the StoreState and returns the inner HashMap.
Sourcepub fn get(&self, key: impl AsRef<str>) -> Option<&Json>
pub fn get(&self, key: impl AsRef<str>) -> Option<&Json>
Gets a reference to the value corresponding to the key.
Sourcepub fn get_mut(&mut self, key: impl AsRef<str>) -> Option<&mut Json>
pub fn get_mut(&mut self, key: impl AsRef<str>) -> Option<&mut Json>
Gets a mutable reference to the value corresponding to the key.
Sourcepub fn try_get<T>(&self, key: impl AsRef<str>) -> Result<T>where
T: DeserializeOwned,
pub fn try_get<T>(&self, key: impl AsRef<str>) -> Result<T>where
T: DeserializeOwned,
Gets a value and tries to parse it as an instance of type T.
Sourcepub fn try_get_or<T>(&self, key: impl AsRef<str>, default: T) -> Twhere
T: DeserializeOwned,
pub fn try_get_or<T>(&self, key: impl AsRef<str>, default: T) -> Twhere
T: DeserializeOwned,
Gets a value and tries to parse it as an instance of type T.
If it does not exist, returns the provided default value.
Sourcepub fn try_get_or_default<T>(&self, key: impl AsRef<str>) -> Twhere
T: DeserializeOwned + Default,
pub fn try_get_or_default<T>(&self, key: impl AsRef<str>) -> Twhere
T: DeserializeOwned + Default,
Gets a value and tries to parse it as an instance of type T.
If it does not exist, returns the default value of T.
Sourcepub fn try_get_or_else<T>(
&self,
key: impl AsRef<str>,
f: impl FnOnce() -> T,
) -> Twhere
T: DeserializeOwned,
pub fn try_get_or_else<T>(
&self,
key: impl AsRef<str>,
f: impl FnOnce() -> T,
) -> Twhere
T: DeserializeOwned,
Gets a value and tries to parse it as an instance of type T.
If it does not exist, returns the result of the provided closure.
Sourcepub fn set(
&mut self,
key: impl AsRef<str>,
value: impl Into<Json>,
) -> Option<Json>
pub fn set( &mut self, key: impl AsRef<str>, value: impl Into<Json>, ) -> Option<Json>
Sets a key-value pair, returning the previous value, if any.
Sourcepub fn patch(&mut self, state: impl Into<StoreState>)
pub fn patch(&mut self, state: impl Into<StoreState>)
Patches the state.
Sourcepub fn values_mut(&mut self) -> impl Iterator<Item = &mut Json>
pub fn values_mut(&mut self) -> impl Iterator<Item = &mut Json>
Creates an iterator over mutable references to the values.
Sourcepub fn entries(&self) -> impl Iterator<Item = (&String, &Json)>
pub fn entries(&self) -> impl Iterator<Item = (&String, &Json)>
Creates an iterator over the entries.
Sourcepub fn entries_mut(&mut self) -> impl Iterator<Item = (&String, &mut Json)>
pub fn entries_mut(&mut self) -> impl Iterator<Item = (&String, &mut Json)>
Creates an iterator over mutable references to the entries.
Sourcepub fn remove(&mut self, key: impl AsRef<str>) -> Option<Json>
pub fn remove(&mut self, key: impl AsRef<str>) -> Option<Json>
Removes a key, returning the previous value, if any.
Trait Implementations§
Source§impl Clone for StoreState
impl Clone for StoreState
Source§fn clone(&self) -> StoreState
fn clone(&self) -> StoreState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StoreState
impl Debug for StoreState
Source§impl Default for StoreState
impl Default for StoreState
Source§fn default() -> StoreState
fn default() -> StoreState
Source§impl<'de> Deserialize<'de> for StoreState
impl<'de> Deserialize<'de> for StoreState
Source§fn deserialize<D>(deserializer: D) -> StdResult<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> StdResult<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<K, V> From<(K, V)> for StoreState
impl<K, V> From<(K, V)> for StoreState
Source§impl<K, V> FromIterator<(K, V)> for StoreState
impl<K, V> FromIterator<(K, V)> for StoreState
Auto Trait Implementations§
impl Freeze for StoreState
impl RefUnwindSafe for StoreState
impl Send for StoreState
impl Sync for StoreState
impl Unpin for StoreState
impl UnwindSafe for StoreState
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,
Source§impl<'de, D, R> CommandArg<'de, R> for Dwhere
D: Deserialize<'de>,
R: Runtime,
impl<'de, D, R> CommandArg<'de, R> for Dwhere
D: Deserialize<'de>,
R: Runtime,
Source§fn from_command(command: CommandItem<'de, R>) -> Result<D, InvokeError>
fn from_command(command: CommandItem<'de, R>) -> Result<D, InvokeError>
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