pub struct Store<R: Runtime> { /* private fields */ }Implementations§
Source§impl<R: Runtime> Store<R>
impl<R: Runtime> Store<R>
Sourcepub fn app_handle(&self) -> &AppHandle<R>
pub fn app_handle(&self) -> &AppHandle<R>
Gets a handle to the application instance.
Sourcepub fn state(&self) -> &StoreState
pub fn state(&self) -> &StoreState
Gets a reference to the store state.
Sourcepub fn try_state<T: DeserializeOwned>(&self) -> Result<T>
pub fn try_state<T: DeserializeOwned>(&self) -> Result<T>
Tries to parse the store state as an instance of type T.
Sourcepub fn try_get<T: DeserializeOwned>(&self, key: impl AsRef<str>) -> Result<T>
pub fn try_get<T: DeserializeOwned>(&self, key: impl AsRef<str>) -> Result<T>
Gets a value from the store 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 from the store and tries to parse it as an instance of type T.
If the key 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 from the store and tries to parse it as an instance of type T.
If the key does not exist, returns the default value of T.
Sourcepub fn try_get_or_else<T, F>(&self, key: impl AsRef<str>, f: F) -> Twhere
T: DeserializeOwned,
F: FnOnce() -> T,
pub fn try_get_or_else<T, F>(&self, key: impl AsRef<str>, f: F) -> Twhere
T: DeserializeOwned,
F: FnOnce() -> T,
Gets a value from the store and tries to parse it as an instance of type T.
If the key does not exist, returns the result of the provided closure.
Sourcepub fn set(
&mut self,
key: impl AsRef<str>,
value: impl Into<Json>,
) -> Result<()>
pub fn set( &mut self, key: impl AsRef<str>, value: impl Into<Json>, ) -> Result<()>
Sets a key-value pair in the store.
Sourcepub fn patch_with_source<S, E>(&mut self, state: S, source: E) -> Result<()>
pub fn patch_with_source<S, E>(&mut self, state: S, source: E) -> Result<()>
Patches the store state, optionally having a window as the source.
Sourcepub fn entries(&self) -> impl Iterator<Item = (&String, &Json)>
pub fn entries(&self) -> impl Iterator<Item = (&String, &Json)>
Creates an iterator over the store entries.
Sourcepub fn save_on_change(&mut self, enabled: bool)
pub fn save_on_change(&mut self, enabled: bool)
Whether to save the store on state change.
Sourcepub fn save_strategy(&self) -> SaveStrategy
pub fn save_strategy(&self) -> SaveStrategy
Current save strategy used by this store.
Sourcepub fn set_save_strategy(&mut self, strategy: SaveStrategy)
pub fn set_save_strategy(&mut self, strategy: SaveStrategy)
Sets the save strategy for this store. Calling this will abort any pending save operation.
Sourcepub fn set_options_with_source<E>(
&mut self,
options: StoreOptions,
source: E,
) -> Result<()>where
E: Into<EventSource>,
pub fn set_options_with_source<E>(
&mut self,
options: StoreOptions,
source: E,
) -> Result<()>where
E: Into<EventSource>,
Sets the store options, optionally having a window as the source.
Sourcepub fn set_options(&mut self, options: StoreOptions) -> Result<()>
pub fn set_options(&mut self, options: StoreOptions) -> Result<()>
Sets the store options.