tauri-plugin-vue 2.2.0

Persistence for Tauri and Vue
Documentation
// THIS FILE WAS AUTOGENERATED AND SHOULD NOT BE EDITED MANUALLY.
//
// Check the `codegen` command in the `tauri-store-cli` crate.
// https://github.com/ferreira-tb/tauri-store/tree/main/crates/tauri-store-cli
//
// To modify the behavior of the plugin, you must either change the
// upstream `tauri-store` crate or update the code generation itself.
// This ensures that all plugins maintain consistent behavior.

use crate::vue::{Vue, VueMarker};
use tauri::{Manager, Runtime};
use tauri_store::{ManagerExt as _, Result, Store};

/// Extension for the [`Manager`] trait providing access to the Vue plugin.
///
/// [`Manager`]: https://docs.rs/tauri/latest/tauri/trait.Manager.html
pub trait ManagerExt<R: Runtime>: Manager<R> {
  /// Returns a handle to the Vue plugin.
  ///
  /// # Panics
  ///
  /// Panics if the internal [store collection] is not yet being managed by Tauri.
  ///
  /// This likely indicates that it was called before the plugin was properly initialized.
  ///
  /// [store collection]: https://docs.rs/tauri-store/latest/tauri_store/struct.StoreCollection.html
  fn vue(&self) -> Vue<'_, R> {
    Vue(
      self
        .app_handle()
        .store_collection_with_marker::<VueMarker>(),
    )
  }

  /// Calls a closure with a mutable reference to the store with the given id.
  fn with_store<F, T>(&self, id: impl AsRef<str>, f: F) -> Result<T>
  where
    F: FnOnce(&mut Store<R, VueMarker>) -> T,
  {
    self
      .app_handle()
      .store_collection_with_marker::<VueMarker>()
      .with_store(id, f)
  }
}

impl<R: Runtime, T: Manager<R>> ManagerExt<R> for T {}