tauri_store

Struct StoreCollection

source
pub struct StoreCollection<R: Runtime> { /* private fields */ }

Implementations§

source§

impl<R: Runtime> StoreCollection<R>

source

pub fn builder() -> StoreCollectionBuilder

source

pub fn path(&self) -> &Path

Directory where the stores are saved.

source

pub fn with_store<F, T>( &self, id: impl AsRef<str>, f: F, ) -> BoxFuture<'_, Result<T>>
where F: FnOnce(&mut Store<R>) -> BoxFuture<'_, Result<T>> + Send + 'static, T: Send + 'static,

Calls a closure with a mutable reference to the store with the given id.

source

pub async fn save(&self, id: impl AsRef<str>) -> Result<()>

Saves a store to the disk.

source

pub async fn save_some(&self, ids: &[impl AsRef<str>]) -> Result<()>

Saves some stores to the disk.

source

pub async fn save_all(&self) -> Result<()>

Saves all the stores to the disk.

source

pub async fn ids(&self) -> Vec<String>

Lists all the store ids.

source

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.

source

pub async fn try_store_state<T>(&self, store_id: impl AsRef<str>) -> Result<T>

Gets the store state if it exists, then tries to deserialize it as an instance of type T.

source

pub async fn get( &self, store_id: impl AsRef<str>, key: impl AsRef<str>, ) -> Option<Json>

Gets a value from a store.

source

pub async fn try_get<T>( &self, store_id: impl AsRef<str>, key: impl AsRef<str>, ) -> Result<T>

Gets a value from a store and tries to interpret it as an instance of type T.

source

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.

source

pub async fn patch( &self, store_id: impl AsRef<str>, state: StoreState, ) -> Result<()>

Patches a store state.

source

pub fn enable_sync(&self, store_id: impl AsRef<str>)

Remove a store from the sync denylist.

source

pub fn disable_sync(&self, store_id: impl AsRef<str>)

Add a store to the sync denylist.

source

pub fn set_autosave(&self, duration: Duration)

Available on crate feature unstable-async only.

Saves the stores periodically.

source

pub fn clear_autosave(&self)

Available on crate feature unstable-async only.

Stops the autosave.

source

pub async fn unload_store(&self, id: &str) -> Result<()>

Trait Implementations§

source§

impl<R: Runtime> Debug for StoreCollection<R>

source§

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

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

impl<R: Runtime> Drop for StoreCollection<R>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<R: Runtime> Resource for StoreCollection<R>

source§

fn name(&self) -> Cow<'_, str>

Returns a string representation of the resource. The default implementation returns the Rust type name, but specific resource types may override this trait method.
source§

fn close(self: Arc<Self>)

Resources may implement the close() trait method if they need to do resource specific clean-ups, such as cancelling pending futures, after a resource has been removed from the resource table.

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> 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> 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, 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.