iced_core/
clipboard.rs

1//! Access the clipboard.
2
3/// A buffer for short-term storage and transfer within and between
4/// applications.
5pub trait Clipboard {
6    /// Reads the current content of the [`Clipboard`] as text.
7    fn read(&self, kind: Kind) -> Option<String>;
8
9    /// Writes the given text contents to the [`Clipboard`].
10    fn write(&mut self, kind: Kind, contents: String);
11}
12
13/// The kind of [`Clipboard`].
14#[derive(Debug, Clone, Copy, PartialEq, Eq)]
15pub enum Kind {
16    /// The standard clipboard.
17    Standard,
18    /// The primary clipboard.
19    ///
20    /// Normally only present in X11 and Wayland.
21    Primary,
22}
23
24/// A null implementation of the [`Clipboard`] trait.
25#[derive(Debug, Clone, Copy)]
26pub struct Null;
27
28impl Clipboard for Null {
29    fn read(&self, _kind: Kind) -> Option<String> {
30        None
31    }
32
33    fn write(&mut self, _kind: Kind, _contents: String) {}
34}