Skip to main content

SystemBackend

Trait SystemBackend 

Source
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§

Source

fn name(&self) -> String

What it is called, for the collector (“egui”, “arboard”).

Source

fn write(&mut self, ctx: &Context, reprs: &[Repr]) -> Result<(), String>

Writes one copy’s representations (richest first, sanitised for the system boundary) at once, replacing what the system clipboard held.

Provided Methods§

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn write_primary(&mut self, text: &str) -> Result<(), String>

Sets the primary selection’s text.

Source

fn describe(&self) -> Json

What it says of itself for the collector: its platform path (on Wayland: XWayland, the data-control protocol, or the core protocol), what it reads and writes.

Implementors§