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
6use crate::vue::{Vue, VueMarker};
7use tauri::{Manager, Runtime};
8use tauri_store::{ManagerExt as _, Result, Store};
9
10/// Extension for the [`Manager`] trait providing access to the Vue plugin.
11///
12/// [`Manager`]: https://docs.rs/tauri/latest/tauri/trait.Manager.html
13pub trait ManagerExt<R: Runtime>: Manager<R> {
14  /// Returns a handle to the Vue plugin.
15  ///
16  /// # Panics
17  ///
18  /// Panics if the internal [store collection] is not yet being managed by Tauri.
19  ///
20  /// This likely indicates that it was called before the plugin was properly initialized.
21  ///
22  /// [store collection]: https://docs.rs/tauri-store/latest/tauri_store/struct.StoreCollection.html
23  fn vue(&self) -> Vue<R> {
24    Vue(
25      self
26        .app_handle()
27        .store_collection_with_marker::<VueMarker>(),
28    )
29  }
30
31  /// Calls a closure with a mutable reference to the store with the given id.
32  fn with_store<F, T>(&self, id: impl AsRef<str>, f: F) -> Result<T>
33  where
34    F: FnOnce(&mut Store<R, VueMarker>) -> T,
35  {
36    self
37      .app_handle()
38      .store_collection_with_marker::<VueMarker>()
39      .with_store(id, f)
40  }
41}
42
43impl<R: Runtime, T: Manager<R>> ManagerExt<R> for T {}