pub struct Valtio<R: Runtime>(/* private fields */);Expand description
The Valtio plugin.
Implementations§
Source§impl<R: Runtime> Valtio<R>
impl<R: Runtime> Valtio<R>
Sourcepub fn clear_autosave(&self)
pub fn clear_autosave(&self)
Stops the autosave.
Sourcepub fn default_save_strategy(&self) -> SaveStrategy
pub fn default_save_strategy(&self) -> SaveStrategy
Default save strategy for the stores. This can be overridden on a per-store basis.
Sourcepub fn get(
&self,
store_id: impl AsRef<str>,
key: impl AsRef<str>,
) -> Option<Json>
pub fn get( &self, store_id: impl AsRef<str>, key: impl AsRef<str>, ) -> Option<Json>
Gets a value from a store.
Sourcepub fn patch(&self, store_id: impl AsRef<str>, state: StoreState) -> Result<()>
pub fn patch(&self, store_id: impl AsRef<str>, state: StoreState) -> Result<()>
Patches a store state.
Sourcepub fn save_all_now(&self) -> Result<()>
pub fn save_all_now(&self) -> Result<()>
Saves all the stores to the disk immediately, ignoring the save strategy.
Sourcepub fn save_now(&self, id: impl AsRef<str>) -> Result<()>
pub fn save_now(&self, id: impl AsRef<str>) -> Result<()>
Saves a store to the disk immediately, ignoring the save strategy.
Sourcepub fn save_some_now(&self, ids: &[impl AsRef<str>]) -> Result<()>
pub fn save_some_now(&self, ids: &[impl AsRef<str>]) -> Result<()>
Saves some stores to the disk immediately, ignoring the save strategy.
Sourcepub fn set(
&self,
id: impl AsRef<str>,
key: impl AsRef<str>,
value: Json,
) -> Result<()>
pub fn set( &self, id: impl AsRef<str>, key: impl AsRef<str>, value: Json, ) -> Result<()>
Sets a key-value pair in a store.
Sourcepub fn set_autosave(&self, duration: Duration)
pub fn set_autosave(&self, duration: Duration)
Saves the stores periodically.
Sourcepub fn store_state(&self, store_id: impl AsRef<str>) -> Result<StoreState>
pub fn store_state(&self, store_id: impl AsRef<str>) -> Result<StoreState>
Gets a clone of the store state if it exists.
Sourcepub fn try_get<T>(
&self,
store_id: impl AsRef<str>,
key: impl AsRef<str>,
) -> Result<T>where
T: DeserializeOwned,
pub fn try_get<T>(
&self,
store_id: impl AsRef<str>,
key: impl AsRef<str>,
) -> Result<T>where
T: DeserializeOwned,
Gets a value from a store and tries to parse it as an instance of type T.
Sourcepub fn try_store_state<T>(&self, store_id: impl AsRef<str>) -> Result<T>where
T: DeserializeOwned,
pub fn try_store_state<T>(&self, store_id: impl AsRef<str>) -> Result<T>where
T: DeserializeOwned,
Gets the store state if it exists, then tries to parse it as an instance of type T.
Sourcepub fn unwatch(
&self,
store_id: impl AsRef<str>,
listener_id: u32,
) -> Result<bool>
pub fn unwatch( &self, store_id: impl AsRef<str>, listener_id: u32, ) -> Result<bool>
Removes a watcher from a store.
Trait Implementations§
Auto Trait Implementations§
impl<R> Freeze for Valtio<R>
impl<R> !RefUnwindSafe for Valtio<R>
impl<R> Send for Valtio<R>
impl<R> Sync for Valtio<R>
impl<R> Unpin for Valtio<R>
impl<R> !UnwindSafe for Valtio<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