iced_runtime/
clipboard.rs1use crate::core::clipboard::Kind;
3use crate::futures::futures::channel::oneshot;
4use crate::task::{self, Task};
5
6#[derive(Debug)]
10pub enum Action {
11 Read {
13 target: Kind,
15 channel: oneshot::Sender<Option<String>>,
17 },
18
19 Write {
21 target: Kind,
23 contents: String,
25 },
26}
27
28pub fn read() -> Task<Option<String>> {
30 task::oneshot(|channel| {
31 crate::Action::Clipboard(Action::Read {
32 target: Kind::Standard,
33 channel,
34 })
35 })
36}
37
38pub fn read_primary() -> Task<Option<String>> {
40 task::oneshot(|channel| {
41 crate::Action::Clipboard(Action::Read {
42 target: Kind::Primary,
43 channel,
44 })
45 })
46}
47
48pub fn write<T>(contents: String) -> Task<T> {
50 task::effect(crate::Action::Clipboard(Action::Write {
51 target: Kind::Standard,
52 contents,
53 }))
54}
55
56pub fn write_primary<Message>(contents: String) -> Task<Message> {
58 task::effect(crate::Action::Clipboard(Action::Write {
59 target: Kind::Primary,
60 contents,
61 }))
62}