StoreState

Struct StoreState 

Source
pub struct StoreState(/* private fields */);
Expand description

Internal state of a store.

Implementations§

Source§

impl StoreState

Source

pub fn new() -> StoreState

Creates an empty StoreState.

Source

pub fn with_capacity(capacity: usize) -> StoreState

Creates an empty StoreState with at least the specified capacity.

Source

pub fn into_inner(self) -> HashMap<String, Value>

Consumes the StoreState and returns the inner HashMap.

Source

pub fn get_raw(&self, key: impl AsRef<str>) -> Option<&Value>

Gets a reference to the raw value corresponding to the key.

Source

pub fn get_raw_mut(&mut self, key: impl AsRef<str>) -> Option<&mut Value>

Gets a mutable reference to the raw value corresponding to the key.

Source

pub unsafe fn get_raw_unchecked(&self, key: impl AsRef<str>) -> &Value

Gets a reference to the raw value corresponding to the key.

§Safety

This is undefined behavior if the key doesn’t exist in the store.

Source

pub unsafe fn get_raw_unchecked_mut( &mut self, key: impl AsRef<str>, ) -> &mut Value

Gets a mutable reference to the raw value corresponding to the key.

§Safety

This is undefined behavior if the key doesn’t exist in the store.

Source

pub fn get<T>(&self, key: impl AsRef<str>) -> Result<T, Error>

Gets a value and tries to parse it as an instance of type T.

Source

pub fn get_or<T>(&self, key: impl AsRef<str>, default: T) -> T

Gets a value and tries to parse it as an instance of type T.

If it does not exist, returns the provided default value.

Source

pub fn get_or_default<T>(&self, key: impl AsRef<str>) -> T

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.

Source

pub fn get_or_else<T>(&self, key: impl AsRef<str>, f: impl FnOnce() -> T) -> T

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.

Source

pub unsafe fn get_unchecked<T>(&self, key: impl AsRef<str>) -> T

Gets a value and parses it as an instance of type T.

§Safety

This is undefined behavior if the key doesn’t exist in the store OR if the value cannot be represented as a valid T.

Source

pub fn set( &mut self, key: impl AsRef<str>, value: impl Into<Value>, ) -> Option<Value>

Sets a key-value pair, returning the previous value, if any.

Source

pub fn patch(&mut self, state: impl Into<StoreState>)

Patches the state.

Source

pub fn has(&self, key: impl AsRef<str>) -> bool

Whether a key exists.

Source

pub fn keys(&self) -> impl Iterator<Item = &String>

Creates an iterator over the keys.

Source

pub fn values(&self) -> impl Iterator<Item = &Value>

Creates an iterator over the values.

Source

pub fn values_mut(&mut self) -> impl Iterator<Item = &mut Value>

Creates an iterator over mutable references to the values.

Source

pub fn entries(&self) -> impl Iterator<Item = (&String, &Value)>

Creates an iterator over the entries.

Source

pub fn entries_mut(&mut self) -> impl Iterator<Item = (&String, &mut Value)>

Creates an iterator over mutable references to the entries.

Source

pub fn remove(&mut self, key: impl AsRef<str>) -> Option<Value>

Removes a key, returning the previous value, if any.

Source

pub fn retain<F>(&mut self, f: F)
where F: FnMut(&String, &mut Value) -> bool,

Retains only the values specified by the predicate.

Source

pub fn clear(&mut self)

Clears the store state, removing all key-value pairs.

Source

pub fn len(&self) -> usize

Returns the amount of items.

Source

pub fn is_empty(&self) -> bool

Whether it is empty.

Trait Implementations§

Source§

impl Clone for StoreState

Source§

fn clone(&self) -> StoreState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StoreState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for StoreState

Source§

fn default() -> StoreState

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for StoreState

Source§

fn deserialize<D>( deserializer: D, ) -> Result<StoreState, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<&StoreState> for Value

Source§

fn from(state: &StoreState) -> Value

Converts to this type from the input type.
Source§

impl<const N: usize, K, V> From<[(K, V); N]> for StoreState
where K: Into<String>, V: Into<Value>,

Source§

fn from(pairs: [(K, V); N]) -> StoreState

Converts to this type from the input type.
Source§

impl<K, V> From<(K, V)> for StoreState
where K: Into<String>, V: Into<Value>,

Source§

fn from(_: (K, V)) -> StoreState

Converts to this type from the input type.
Source§

impl From<HashMap<String, Value>> for StoreState

Source§

fn from(map: HashMap<String, Value>) -> StoreState

Converts to this type from the input type.
Source§

impl From<StoreState> for Value

Source§

fn from(state: StoreState) -> Value

Converts to this type from the input type.
Source§

impl<K, V> From<Vec<(K, V)>> for StoreState
where K: Into<String>, V: Into<Value>,

Source§

fn from(pairs: Vec<(K, V)>) -> StoreState

Converts to this type from the input type.
Source§

impl<K, V> FromIterator<(K, V)> for StoreState
where K: Into<String>, V: Into<Value>,

Source§

fn from_iter<I>(iter: I) -> StoreState
where I: IntoIterator<Item = (K, V)>,

Creates a value from an iterator. Read more
Source§

impl Serialize for StoreState

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<'de, D, R> CommandArg<'de, R> for D
where D: Deserialize<'de>, R: Runtime,

Source§

fn from_command(command: CommandItem<'de, R>) -> Result<D, InvokeError>

Derives an instance of Self from the CommandItem. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IpcResponse for T
where T: Serialize,

Source§

fn body(self) -> Result<InvokeResponseBody, Error>

Resolve the IPC response body.
Source§

impl<T> ScopeObject for T
where T: Send + Sync + Debug + DeserializeOwned + 'static,

Source§

type Error = Error

The error type.
Source§

fn deserialize<R>( _app: &AppHandle<R>, raw: Value, ) -> Result<T, <T as ScopeObject>::Error>
where R: Runtime,

Deserialize the raw scope value.
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> UserEvent for T
where T: Debug + Clone + Send + 'static,