tauri_plugin_wallpaper/
lib.rs1use tauri::{
2 plugin::{Builder, TauriPlugin},
3 Manager, Runtime,
4};
5
6pub use models::*;
7
8#[cfg(desktop)]
9mod desktop;
10
11mod commands;
12mod error;
13mod models;
14
15mod platform;
16
17pub use error::{Error, Result};
18
19#[cfg(desktop)]
20use desktop::Wallpaper;
21
22pub trait WallpaperExt<R: Runtime> {
23 fn wallpaper(&self) -> &Wallpaper<R>;
24}
25
26impl<R: Runtime, T: Manager<R>> crate::WallpaperExt<R> for T {
27 fn wallpaper(&self) -> &Wallpaper<R> {
28 self.state::<Wallpaper<R>>().inner()
29 }
30}
31
32pub fn init<R: Runtime>() -> TauriPlugin<R> {
33 Builder::new("wallpaper")
34 .invoke_handler(tauri::generate_handler![
35 commands::attach,
36 commands::detach,
37 commands::reset
38 ])
39 .setup(|app, api| {
40 #[cfg(desktop)]
41 let wallpaper = desktop::init(app, api)?;
42 app.manage(wallpaper);
43 Ok(())
44 })
45 .build()
46}