use crate::zustand::{Zustand, ZustandMarker};
use tauri::{Manager, Runtime};
use tauri_store::{ManagerExt as _, Result, Store};
pub trait ManagerExt<R: Runtime>: Manager<R> {
fn zustand(&self) -> Zustand<'_, R> {
Zustand(
self
.app_handle()
.store_collection_with_marker::<ZustandMarker>(),
)
}
fn with_store<F, T>(&self, id: impl AsRef<str>, f: F) -> Result<T>
where
F: FnOnce(&mut Store<R, ZustandMarker>) -> T,
{
self
.app_handle()
.store_collection_with_marker::<ZustandMarker>()
.with_store(id, f)
}
}
impl<R: Runtime, T: Manager<R>> ManagerExt<R> for T {}