Download packages/tauri-plugins/plugins/clipboard-manager/src/lib.rs from echodict/readest: direct link, hf CLI and curl.
- Browser
- Download file 1.87 kB
-
https://huggingface.co/datasets/echodict/readest/resolve/main/packages/tauri-plugins/plugins/clipboard-manager/src/lib.rs
- Command line
-
hf download hf://datasets/echodict/readest/packages/tauri-plugins/plugins/clipboard-manager/src/lib.rs
-
curl -L -o lib.rs https://huggingface.co/datasets/echodict/readest/resolve/main/packages/tauri-plugins/plugins/clipboard-manager/src/lib.rs
1.87 kB
| // Copyright 2019-2023 Tauri Programme within The Commons Conservancy | |
| // SPDX-License-Identifier: Apache-2.0 | |
| // SPDX-License-Identifier: MIT | |
| //! Read and write to the system clipboard. | |
| use tauri::{ | |
| plugin::{Builder, TauriPlugin}, | |
| Manager, RunEvent, Runtime, | |
| }; | |
| mod desktop; | |
| mod mobile; | |
| mod commands; | |
| mod error; | |
| pub use error::{Error, Result}; | |
| pub use desktop::Clipboard; | |
| pub use mobile::Clipboard; | |
| /// Extensions to [`tauri::App`], [`tauri::AppHandle`], [`tauri::WebviewWindow`], [`tauri::Webview`] and [`tauri::Window`] to access the clipboard APIs. | |
| pub trait ClipboardExt<R: Runtime> { | |
| fn clipboard(&self) -> &Clipboard<R>; | |
| } | |
| impl<R: Runtime, T: Manager<R>> crate::ClipboardExt<R> for T { | |
| fn clipboard(&self) -> &Clipboard<R> { | |
| self.state::<Clipboard<R>>().inner() | |
| } | |
| } | |
| /// Initializes the plugin. | |
| pub fn init<R: Runtime>() -> TauriPlugin<R> { | |
| Builder::new("clipboard-manager") | |
| .invoke_handler(tauri::generate_handler![ | |
| commands::write_text, | |
| commands::read_text, | |
| commands::read_image, | |
| commands::write_image, | |
| commands::write_html, | |
| commands::clear | |
| ]) | |
| .setup(|app, api| { | |
| let clipboard = mobile::init(app, api)?; | |
| let clipboard = desktop::init(app, api)?; | |
| app.manage(clipboard); | |
| Ok(()) | |
| }) | |
| .on_event(|_app, _event| { | |
| if let RunEvent::Exit = _event { | |
| _app.clipboard().cleanup(); | |
| } | |
| }) | |
| .build() | |
| } | |