tauri_store

Struct Store

Source
pub struct Store<R: Runtime> { /* private fields */ }

Implementations§

Source§

impl<R: Runtime> Store<R>

Source

pub fn id(&self) -> &str

The id of the store.

Source

pub fn path(&self) -> PathBuf

Path to the store file.

Source

pub fn app_handle(&self) -> &AppHandle<R>

Gets a handle to the application instance.

Source

pub fn state(&self) -> &StoreState

Gets a reference to the store state.

Source

pub fn try_state<T: DeserializeOwned>(&self) -> Result<T>

Tries to parse the store state as an instance of type T.

Source

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

Gets a value from the store.

Source

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.

Source

pub fn has(&self, key: impl AsRef<str>) -> bool

Whether the store has a key.

Source

pub fn keys(&self) -> impl Iterator<Item = &String>

Creates an iterator over the store keys.

Source

pub fn values(&self) -> impl Iterator<Item = &Json>

Creates an iterator over the store values.

Source

pub fn entries(&self) -> impl Iterator<Item = (&String, &Json)>

Creates an iterator over the store entries.

Source

pub fn len(&self) -> usize

Returns the amount of items in the store.

Source

pub fn is_empty(&self) -> bool

Whether the store is empty.

Source

pub fn save_on_change(&mut self, enabled: bool)

Whether to save the store on state change.

Source

pub fn save_strategy(&self) -> SaveStrategy

Current save strategy used by this store.

Source

pub fn set_save_strategy(&mut self, strategy: SaveStrategy)

Sets the save strategy for this store. Calling this will abort any pending save operation.

Source

pub fn set_options_with_source<S>( &mut self, options: StoreOptions, source: S, ) -> Result<()>
where S: Into<EventSource>,

Sets the store options, optionally having a window as the source.

Source

pub fn set_options(&mut self, options: StoreOptions) -> Result<()>

Sets the store options.

Source

pub fn watch<F>(&mut self, f: F) -> u32
where F: Fn(AppHandle<R>) -> WatcherResult + Send + Sync + 'static,

Watches the store for changes.

Source

pub fn unwatch(&mut self, id: u32) -> bool

Removes a listener from this store.

Source§

impl<R: Runtime> Store<R>

Source

pub fn set(&mut self, key: impl AsRef<str>, value: Json) -> Result<()>

Sets a key-value pair in the store.

Source

pub fn patch_with_source<S>( &mut self, state: StoreState, source: S, ) -> Result<()>
where S: Into<EventSource>,

Patches the store state, optionally having a window as the source.

Source

pub fn patch(&mut self, state: StoreState) -> Result<()>

Patches the store state.

Source

pub fn save(&self) -> Result<()>

Save the store state to the disk.

Source

pub fn save_now(&self) -> Result<()>

Save the store immediately, ignoring the save strategy.

Trait Implementations§

Source§

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

Source§

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

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

impl<R: Runtime> From<&Store<R>> for StoreOptions

Source§

fn from(store: &Store<R>) -> Self

Converts to this type from the input type.

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> 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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T