pub struct Store<R: Runtime> { /* private fields */ }Implementations§
Source§impl<R: Runtime> Store<R>
impl<R: Runtime> Store<R>
Sourcepub fn set(&self, key: impl Into<String>, value: impl Into<JsonValue>)
pub fn set(&self, key: impl Into<String>, value: impl Into<JsonValue>)
Inserts a key-value pair into the store.
Sourcepub fn get(&self, key: impl AsRef<str>) -> Option<JsonValue>
pub fn get(&self, key: impl AsRef<str>) -> Option<JsonValue>
Returns the value for the given key or None if the key does not exist.
Sourcepub fn has(&self, key: impl AsRef<str>) -> bool
pub fn has(&self, key: impl AsRef<str>) -> bool
Returns true if the given key exists in the store.
Sourcepub fn clear(&self)
pub fn clear(&self)
Clears the store, removing all key-value pairs.
Note: To clear the storage and reset it to its default value, use reset instead.
Sourcepub fn reset(&self)
pub fn reset(&self)
Resets the store to its default value.
If no default value has been set, this method behaves identical to clear.
Sourcepub fn entries(&self) -> Vec<(String, JsonValue)>
pub fn entries(&self) -> Vec<(String, JsonValue)>
Returns a list of all key-value pairs in the store.
Sourcepub fn reload(&self) -> Result<()>
pub fn reload(&self) -> Result<()>
Update the store from the on-disk state
Note:
- This method loads the data and merges it with the current store,
this behavior will be changed to resetting to default first and then merging with the on-disk state in v3,
to fully match the store with the on-disk state,
use
reload_override_defaultsinstead - This method does not emit change events
Sourcepub fn reload_ignore_defaults(&self) -> Result<()>
pub fn reload_ignore_defaults(&self) -> Result<()>
Load the store from the on-disk state, ignoring defaults
Note: This method does not emit change events
Sourcepub fn close_resource(&self)
pub fn close_resource(&self)
Removes the store from the resource table
Trait Implementations§
Auto Trait Implementations§
impl<R> Freeze for Store<R>
impl<R> RefUnwindSafe for Store<R>
impl<R> Send for Store<R>
impl<R> Sync for Store<R>
impl<R> Unpin for Store<R>
impl<R> UnwindSafe for Store<R>
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