pub struct Vue<'a, R: Runtime>(/* private fields */);
Expand description
The Vue plugin.
Implementations§
Source§impl<'a, R: Runtime> Vue<'a, R>
impl<'a, R: Runtime> Vue<'a, R>
Sourcepub fn set_path(&self, path: impl AsRef<Path>) -> Result<()>
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.
Sourcepub fn with_store<F, T>(&self, id: impl AsRef<str>, f: F) -> Result<T>
pub fn with_store<F, T>(&self, id: impl AsRef<str>, f: F) -> Result<T>
Calls a closure with a mutable reference to the store with the given id.
Sourcepub fn state(&self, store_id: impl AsRef<str>) -> Result<StoreState>
pub fn state(&self, store_id: impl AsRef<str>) -> Result<StoreState>
Gets a clone of the store state if it exists.
Sourcepub fn try_state<T>(&self, store_id: impl AsRef<str>) -> Result<T>where
T: DeserializeOwned,
pub fn try_state<T>(&self, store_id: impl AsRef<str>) -> Result<T>where
T: DeserializeOwned,
Gets the store state, then tries to parse it as an instance of type T
.
Sourcepub fn try_state_or<T>(
&self,
store_id: impl AsRef<str>,
default: T,
) -> Result<T>where
T: DeserializeOwned,
pub fn try_state_or<T>(
&self,
store_id: impl AsRef<str>,
default: T,
) -> Result<T>where
T: DeserializeOwned,
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.
Sourcepub fn try_state_or_default<T>(&self, store_id: impl AsRef<str>) -> Result<T>where
T: DeserializeOwned + Default,
pub fn try_state_or_default<T>(&self, store_id: impl AsRef<str>) -> Result<T>where
T: DeserializeOwned + Default,
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
.
Sourcepub fn try_state_or_else<T>(
&self,
store_id: impl AsRef<str>,
f: impl FnOnce() -> T,
) -> Result<T>where
T: DeserializeOwned,
pub fn try_state_or_else<T>(
&self,
store_id: impl AsRef<str>,
f: impl FnOnce() -> T,
) -> Result<T>where
T: DeserializeOwned,
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.
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 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_get_or<T>(
&self,
store_id: impl AsRef<str>,
key: impl AsRef<str>,
default: T,
) -> Twhere
T: DeserializeOwned,
pub fn try_get_or<T>(
&self,
store_id: impl AsRef<str>,
key: impl AsRef<str>,
default: T,
) -> Twhere
T: DeserializeOwned,
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.
Sourcepub fn try_get_or_default<T>(
&self,
store_id: impl AsRef<str>,
key: impl AsRef<str>,
) -> Twhere
T: Default + DeserializeOwned,
pub fn try_get_or_default<T>(
&self,
store_id: impl AsRef<str>,
key: impl AsRef<str>,
) -> Twhere
T: Default + DeserializeOwned,
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
.
Sourcepub fn try_get_or_else<T, F>(
&self,
store_id: impl AsRef<str>,
key: impl AsRef<str>,
f: F,
) -> Twhere
T: DeserializeOwned,
F: FnOnce() -> T,
pub fn try_get_or_else<T, F>(
&self,
store_id: impl AsRef<str>,
key: impl AsRef<str>,
f: F,
) -> Twhere
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.
Sourcepub fn set<K, V>(&self, id: impl AsRef<str>, key: K, value: V) -> Result<()>
pub fn set<K, V>(&self, id: impl AsRef<str>, key: K, value: V) -> Result<()>
Sets a key-value pair in a store.
Sourcepub fn patch<S>(&self, store_id: impl AsRef<str>, state: S) -> Result<()>where
S: Into<StoreState>,
pub fn patch<S>(&self, store_id: impl AsRef<str>, state: S) -> Result<()>where
S: Into<StoreState>,
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 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 set_autosave(&self, duration: Duration)
pub fn set_autosave(&self, duration: Duration)
Saves the stores periodically.
Sourcepub fn clear_autosave(&self)
pub fn clear_autosave(&self)
Stops the autosave.
Sourcepub fn watch<F>(&self, store_id: impl AsRef<str>, f: F) -> Result<WatcherId>
pub fn watch<F>(&self, store_id: impl AsRef<str>, f: F) -> Result<WatcherId>
Watches a store for changes.
Sourcepub fn unwatch(
&self,
store_id: impl AsRef<str>,
watcher_id: impl Into<WatcherId>,
) -> Result<bool>
pub fn unwatch( &self, store_id: impl AsRef<str>, watcher_id: impl Into<WatcherId>, ) -> Result<bool>
Removes a watcher from a store.
Sourcepub fn allow_save(&self, id: impl AsRef<str>)
pub fn allow_save(&self, id: impl AsRef<str>)
Removes a store from the save denylist.
Sourcepub fn allow_sync(&self, id: impl AsRef<str>)
pub fn allow_sync(&self, id: impl AsRef<str>)
Removes a store from the sync 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> 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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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