pub trait SystemBackend {
// Required methods
fn name(&self) -> String;
fn write(&mut self, ctx: &Context, reprs: &[Repr]) -> Result<(), String>;
// Provided methods
fn writes(&self, format: &FormatId) -> bool { ... }
fn read(&mut self, ctx: &Context) -> Option<Vec<Repr>> { ... }
fn readable(&self) -> Vec<FormatId> { ... }
fn read_primary(&mut self) -> Option<String> { ... }
fn write_primary(&mut self, text: &str) -> Result<(), String> { ... }
fn describe(&self) -> Json { ... }
}Expand description
The system clipboard as egui-pop writes and reads it: what one copy leaves there for other applications, what a paste finds there.
The default, EguiText, writes the text through egui and reads
nothing (a paste knows only the text the paste key brought). A host
gives its own through Clipboard::system, an application installs
one with set_backend (egui-pop-platform’s clipboard feature
has one over arboard: files, images, HTML and the primary
selection).
Representations follow the formats’ usual data: text, HTML and a
URI list (text/uri-list, one file:// URI per line, CRLF between)
are JSON strings; an image (image/png) is a string, the PNG file’s
bytes in standard base64; a private type is its JSON payload.
Required Methods§
Provided Methods§
Sourcefn writes(&self, format: &FormatId) -> bool
fn writes(&self, format: &FormatId) -> bool
Whether it writes a format: a copy gives it every representation it writes, so a private type crosses only where it can.
Sourcefn read(&mut self, ctx: &Context) -> Option<Vec<Repr>>
fn read(&mut self, ctx: &Context) -> Option<Vec<Repr>>
What the system clipboard holds, in each format it reads, richest
first; None when it cannot read (a paste then knows only the
text the paste key brought), empty when the clipboard is.
Sourcefn readable(&self) -> Vec<FormatId>
fn readable(&self) -> Vec<FormatId>
The formats a read may bring besides text, so that the paste command is enabled for a target taking only files or images.
Sourcefn read_primary(&mut self) -> Option<String>
fn read_primary(&mut self) -> Option<String>
The primary selection’s text (X11 and Wayland: select to copy,
middle-click to paste); None where there is none.