Skip to main content

tauri_plugin_vicons/
lib.rs

1use tauri::{
2    plugin::{Builder, TauriPlugin},
3    Manager, Runtime,
4};
5mod cache;
6mod commands;
7mod desktop;
8mod error;
9mod logger;
10mod models;
11mod paths;
12
13pub use error::{Error, Result};
14
15use desktop::Vicons;
16
17pub trait ViconsExt<R: Runtime> {
18    fn vicons(&self) -> &Vicons<R>;
19}
20
21impl<R: Runtime, T: Manager<R>> crate::ViconsExt<R> for T {
22    fn vicons(&self) -> &Vicons<R> {
23        self.state::<Vicons<R>>().inner()
24    }
25}
26
27/// Initializes the plugin.
28pub fn init<R: Runtime>() -> TauriPlugin<R> {
29    Builder::new("vicons")
30        .invoke_handler(tauri::generate_handler![
31            commands::get_icon,
32            commands::get_symbol,
33            commands::has_icon,
34            commands::has_symbol
35        ])
36        .setup(|app, api| {
37            let vicons = desktop::init(app, api)?;
38            app.manage(vicons);
39            Ok(())
40        })
41        .build()
42}