Struct Vue

Source
pub struct Vue<'a, R: Runtime>(/* private fields */);
Expand description

The Vue plugin.

Implementations§

Source§

impl<'a, R: Runtime> Vue<'a, R>

Source

pub fn ids(&self) -> Vec<StoreId>

Lists all the store ids.

Source

pub fn path(&self) -> PathBuf

Directory where the stores are saved.

Source

pub fn set_path(&self, path: impl AsRef<Path>) -> Result<()>

Sets the directory where the stores are saved. This will move all currently active stores to the new directory.

Source

pub fn with_store<F, T>(&self, id: impl AsRef<str>, f: F) -> Result<T>
where F: FnOnce(&mut Store<R, VueMarker>) -> T,

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

Source

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

Gets a clone of the store state if it exists.

Source

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

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

Source

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

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

If it cannot be parsed, returns the provided default value.

Source

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

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

If it cannot be parsed, returns the default value of T.

Source

pub fn try_state_or_else<T>( &self, store_id: impl AsRef<str>, f: impl FnOnce() -> T, ) -> Result<T>

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

If it cannot be parsed, returns the result of the provided closure.

Source

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

Gets a value from a store.

Source

pub 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 parse it as an instance of type T.

Source

pub fn try_get_or<T>( &self, store_id: impl AsRef<str>, key: impl AsRef<str>, default: T, ) -> T

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

If the key does not exist, returns the provided default value.

Source

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

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

If the key does not exist, returns the default value of T.

Source

pub fn try_get_or_else<T, F>( &self, store_id: impl AsRef<str>, key: impl AsRef<str>, f: F, ) -> T
where T: DeserializeOwned, F: FnOnce() -> T,

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

If the key does not exist, returns the result of the provided closure.

Source

pub fn set<K, V>(&self, id: impl AsRef<str>, key: K, value: V) -> Result<()>
where K: AsRef<str>, V: Into<Json>,

Sets a key-value pair in a store.

Source

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

Patches a store state.

Source

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

Saves a store to the disk.

Source

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

Saves all the stores to the disk.

Source

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

Saves all the stores to the disk immediately, ignoring the save strategy.

Source

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

Saves a store to the disk immediately, ignoring the save strategy.

Source

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

Saves some stores to the disk.

Source

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

Saves some stores to the disk immediately, ignoring the save strategy.

Source

pub fn default_save_strategy(&self) -> SaveStrategy

Default save strategy for the stores. This can be overridden on a per-store basis.

Source

pub fn set_autosave(&self, duration: Duration)

Saves the stores periodically.

Source

pub fn clear_autosave(&self)

Stops the autosave.

Source

pub fn watch<F>(&self, store_id: impl AsRef<str>, f: F) -> Result<WatcherId>
where F: Fn(AppHandle<R>) -> Result<()> + Send + Sync + 'static,

Watches a store for changes.

Source

pub fn unwatch( &self, store_id: impl AsRef<str>, watcher_id: impl Into<WatcherId>, ) -> Result<bool>

Removes a watcher from a store.

Source

pub fn allow_save(&self, id: impl AsRef<str>)

Removes a store from the save denylist.

Source

pub fn deny_save(&self, id: impl AsRef<str>)

Adds a store to the save denylist.

Source

pub fn allow_sync(&self, id: impl AsRef<str>)

Removes a store from the sync denylist.

Source

pub fn deny_sync(&self, id: impl AsRef<str>)

Adds a store to the deny denylist.

Auto Trait Implementations§

§

impl<'a, R> Freeze for Vue<'a, R>

§

impl<'a, R> !RefUnwindSafe for Vue<'a, R>

§

impl<'a, R> Send for Vue<'a, R>

§

impl<'a, R> Sync for Vue<'a, R>

§

impl<'a, R> Unpin for Vue<'a, R>

§

impl<'a, R> !UnwindSafe for Vue<'a, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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,