tauri_plugin_vue/
manager.rs

1// THIS FILE WAS AUTOGENERATED AND SHOULD NOT BE EDITED MANUALLY.
2//
3// Check the `codegen` command in the `tauri-store-cli` crate.
4// https://github.com/ferreira-tb/tauri-store/tree/main/crates/tauri-store-cli
5//
6// To modify the behavior of the plugin, you must either change the
7// upstream `tauri-store` crate or update the code generation itself.
8// This ensures that all plugins maintain consistent behavior.
9
10use crate::vue::{Vue, VueMarker};
11use tauri::{Manager, Runtime};
12use tauri_store::{ManagerExt as _, Result, Store};
13
14/// Extension for the [`Manager`] trait providing access to the Vue plugin.
15///
16/// [`Manager`]: https://docs.rs/tauri/latest/tauri/trait.Manager.html
17pub trait ManagerExt<R: Runtime>: Manager<R> {
18  /// Returns a handle to the Vue plugin.
19  ///
20  /// # Panics
21  ///
22  /// Panics if the internal [store collection] is not yet being managed by Tauri.
23  ///
24  /// This likely indicates that it was called before the plugin was properly initialized.
25  ///
26  /// [store collection]: https://docs.rs/tauri-store/latest/tauri_store/struct.StoreCollection.html
27  fn vue(&self) -> Vue<'_, R> {
28    Vue(
29      self
30        .app_handle()
31        .store_collection_with_marker::<VueMarker>(),
32    )
33  }
34
35  /// Calls a closure with a mutable reference to the store with the given id.
36  fn with_store<F, T>(&self, id: impl AsRef<str>, f: F) -> Result<T>
37  where
38    F: FnOnce(&mut Store<R, VueMarker>) -> T,
39  {
40    self
41      .app_handle()
42      .store_collection_with_marker::<VueMarker>()
43      .with_store(id, f)
44  }
45}
46
47impl<R: Runtime, T: Manager<R>> ManagerExt<R> for T {}