retrom_plugin_config/
lib.rs1use config_manager::ConfigManager;
2use tauri::{
3 plugin::{Builder, TauriPlugin},
4 Manager, Runtime,
5};
6
7mod commands;
8mod config_manager;
9mod error;
10
11pub use error::{Error, Result};
12
13pub trait ConfigExt<R: Runtime> {
15 fn config_manager(&self) -> &ConfigManager<R>;
16}
17
18impl<R: Runtime, T: Manager<R>> crate::ConfigExt<R> for T {
19 fn config_manager(&self) -> &ConfigManager<R> {
20 self.state::<ConfigManager<R>>().inner()
21 }
22}
23
24pub fn init<R: Runtime>() -> TauriPlugin<R> {
26 Builder::new("config")
27 .invoke_handler(tauri::generate_handler![
28 commands::get_config,
29 commands::set_config
30 ])
31 .setup(|app, api| {
32 let config_manager = config_manager::init(app, api)?;
33 app.manage(config_manager);
34 Ok(())
35 })
36 .build()
37}