tauri_plugin_clipboard_next/
lib.rs1use tauri::{
2 plugin::{Builder, TauriPlugin},
3 Manager, Runtime,
4};
5
6pub use models::*;
7
8#[cfg(desktop)]
9mod desktop;
10#[cfg(mobile)]
11mod mobile;
12
13mod commands;
14mod error;
15mod models;
16mod utils;
17mod constants;
18
19pub use error::*;
20
21#[cfg(desktop)]
22use desktop::ClipboardNext;
23#[cfg(mobile)]
24use mobile::ClipboardNext;
25
26pub trait ClipboardNextExt<R: Runtime> {
28 fn clipboard_next(&self) -> &ClipboardNext<R>;
29}
30
31impl<R: Runtime, T: Manager<R>> ClipboardNextExt<R> for T {
32 fn clipboard_next(&self) -> &ClipboardNext<R> {
33 self.state::<ClipboardNext<R>>().inner()
34 }
35}
36
37pub fn init<R: Runtime>() -> TauriPlugin<R> {
39 Builder::new("clipboard-next")
40 .invoke_handler(tauri::generate_handler![
41 commands::start_watch,
42 commands::stop_watch,
43 commands::has_text,
44 commands::has_rtf,
45 commands::has_html,
46 commands::has_image,
47 commands::has_files,
48 commands::read_text,
49 commands::read_rtf,
50 commands::read_html,
51 commands::read_image,
52 commands::read_files,
53 commands::write_text,
54 commands::write_rtf,
55 commands::write_html,
56 commands::write_image,
57 commands::write_files,
58 commands::clear,
59 commands::get_file_path,
60 ])
61 .setup(|app, api| {
62 #[cfg(mobile)]
63 let clipboard_next = mobile::init(app, api)?;
64
65 #[cfg(desktop)]
66 let clipboard_next = desktop::init(app, api)?;
67
68 app.manage(clipboard_next);
69 Ok(())
70 })
71 .build()
72}