t_rust_less_lib/clipboard/
mod.rs1mod error;
2#[cfg(all(unix, not(target_os = "android"), feature = "with_x11", feature = "with_wayland"))]
3mod unix_mixed;
4#[cfg(any(
5 target_os = "android",
6 all(unix, not(any(feature = "with_x11", feature = "with_wayland")))
7))]
8mod unix_none;
9#[cfg(all(unix, not(target_os = "android"), feature = "with_wayland"))]
10pub mod unix_wayland;
11#[cfg(all(unix, not(target_os = "android"), feature = "with_x11"))]
12mod unix_x11;
13#[cfg(windows)]
14mod windows;
15
16use zeroize::Zeroizing;
17
18#[cfg(not(windows))]
19mod selection_provider_holder;
20
21use std::sync::Arc;
22
23use crate::api::{ClipboardProviding, EventHub};
24
25pub use self::error::*;
26#[cfg(all(unix, not(target_os = "android"), feature = "with_x11", feature = "with_wayland"))]
27pub use self::unix_mixed::Clipboard;
28#[cfg(any(
29 target_os = "android",
30 all(unix, not(any(feature = "with_x11", feature = "with_wayland")))
31))]
32pub use self::unix_none::Clipboard;
33#[cfg(all(
34 unix,
35 not(target_os = "android"),
36 feature = "with_wayland",
37 not(feature = "with_x11")
38))]
39pub use self::unix_wayland::Clipboard;
40#[cfg(all(
41 unix,
42 not(target_os = "android"),
43 feature = "with_x11",
44 not(feature = "with_wayland")
45))]
46pub use self::unix_x11::Clipboard;
47#[cfg(windows)]
48pub use self::windows::Clipboard;
49
50pub trait SelectionProvider: Send + Sync {
51 fn current_selection(&self) -> Option<ClipboardProviding>;
52
53 fn get_selection_value(&self) -> Option<Zeroizing<String>>;
54
55 fn next_selection(&mut self);
56}
57
58pub trait ClipboardCommon: Sized {
59 fn new<T>(selection_provider: T, event_hub: Arc<dyn EventHub>) -> ClipboardResult<Self>
60 where
61 T: SelectionProvider + Clone + 'static;
62
63 fn destroy(&self);
64
65 fn is_open(&self) -> bool;
66
67 fn currently_providing(&self) -> Option<ClipboardProviding>;
68
69 fn provide_next(&self);
70
71 fn wait(&self) -> ClipboardResult<()>;
72}