Skip to main content

Clipboard

Trait Clipboard 

Source
pub trait Clipboard: Send + Sync {
    // Required methods
    fn read(&self) -> Option<String>;
    fn write(&self, text: String);
}
Expand description

The OS clipboard, behind a swappable backend.

Implementors: ArboardClipboard + OSC52 fallback (TUI, CB.2), the gpui-native bridge (GPUI peer, CB.4), and FakeClipboard (tests / CI). All reads/writes are text-only for v1 (images / other MIME are out of scope).

Required Methods§

Source

fn read(&self) -> Option<String>

Read the clipboard’s current text. None when the clipboard is empty, holds non-text content, or the backend can’t read (e.g. OSC52 over SSH, where read-back is unsupported — the register layer falls back to its in-memory entry). Only called from a spawn_blocking context.

Source

fn write(&self, text: String)

Write text to the clipboard. Fire-and-forget: never blocks the caller. A backend whose write would block spawns its own blocking task.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§