pub struct StoreCollection<R: Runtime> { /* private fields */ }Implementations§
source§impl<R: Runtime> StoreCollection<R>
impl<R: Runtime> StoreCollection<R>
pub fn builder() -> StoreCollectionBuilder
sourcepub fn with_store<F, T>(
&self,
id: impl AsRef<str>,
f: F,
) -> BoxFuture<'_, Result<T>>
pub fn with_store<F, T>( &self, id: impl AsRef<str>, f: F, ) -> BoxFuture<'_, Result<T>>
Calls a closure with a mutable reference to the store with the given id.
sourcepub async fn save_some(&self, ids: &[impl AsRef<str>]) -> Result<()>
pub async fn save_some(&self, ids: &[impl AsRef<str>]) -> Result<()>
Saves some stores to the disk.
sourcepub async fn store_state(&self, store_id: impl AsRef<str>) -> Option<StoreState>
pub async fn store_state(&self, store_id: impl AsRef<str>) -> Option<StoreState>
Gets a clone of the store state if it exists.
WARNING: Changes to the returned state will not be reflected in the store.
sourcepub async fn try_store_state<T>(&self, store_id: impl AsRef<str>) -> Result<T>where
T: DeserializeOwned,
pub async 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 deserialize it as an instance of type T.
sourcepub async fn get(
&self,
store_id: impl AsRef<str>,
key: impl AsRef<str>,
) -> Option<Json>
pub async fn get( &self, store_id: impl AsRef<str>, key: impl AsRef<str>, ) -> Option<Json>
Gets a value from a store.
sourcepub async fn try_get<T>(
&self,
store_id: impl AsRef<str>,
key: impl AsRef<str>,
) -> Result<T>where
T: DeserializeOwned,
pub async 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 interpret it as an instance of type T.
sourcepub async fn set(
&self,
store_id: impl AsRef<str>,
key: impl AsRef<str>,
value: Json,
) -> Result<()>
pub async fn set( &self, store_id: impl AsRef<str>, key: impl AsRef<str>, value: Json, ) -> Result<()>
Sets a key-value pair in a store.
sourcepub async fn patch(
&self,
store_id: impl AsRef<str>,
state: StoreState,
) -> Result<()>
pub async fn patch( &self, store_id: impl AsRef<str>, state: StoreState, ) -> Result<()>
Patches a store state.
sourcepub fn enable_sync(&self, store_id: impl AsRef<str>)
pub fn enable_sync(&self, store_id: impl AsRef<str>)
Remove a store from the sync denylist.
sourcepub fn disable_sync(&self, store_id: impl AsRef<str>)
pub fn disable_sync(&self, store_id: impl AsRef<str>)
Add a store to the sync denylist.
sourcepub fn set_autosave(&self, duration: Duration)
Available on crate feature unstable-async only.
pub fn set_autosave(&self, duration: Duration)
unstable-async only.Saves the stores periodically.
sourcepub fn clear_autosave(&self)
Available on crate feature unstable-async only.
pub fn clear_autosave(&self)
unstable-async only.Stops the autosave.
pub async fn unload_store(&self, id: &str) -> Result<()>
Trait Implementations§
source§impl<R: Runtime> Debug for StoreCollection<R>
impl<R: Runtime> Debug for StoreCollection<R>
source§impl<R: Runtime> Drop for StoreCollection<R>
impl<R: Runtime> Drop for StoreCollection<R>
Auto Trait Implementations§
impl<R> !Freeze for StoreCollection<R>
impl<R> !RefUnwindSafe for StoreCollection<R>
impl<R> Send for StoreCollection<R>
impl<R> Sync for StoreCollection<R>
impl<R> Unpin for StoreCollection<R>
impl<R> !UnwindSafe for StoreCollection<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