Skip to main content

FakeClipboard

Struct FakeClipboard 

Source
pub struct FakeClipboard { /* private fields */ }
Expand description

In-memory Clipboard for tests / headless CI and the default boot binding before a real backend is installed (CB.2 / CB.4). Thread-safe; round-trips text without touching any OS resource.

§Examples

use lattice_core::{Clipboard, ClipboardHandle, FakeClipboard};
use std::sync::Arc;

let clip: ClipboardHandle = Arc::new(FakeClipboard::new());
assert_eq!(clip.read(), None); // starts empty
clip.write("yanked".to_string());
assert_eq!(clip.read().as_deref(), Some("yanked"));

Implementations§

Source§

impl FakeClipboard

Source

pub fn new() -> Self

An empty clipboard: Clipboard::read returns None until the first write.

Trait Implementations§

Source§

impl Clipboard for FakeClipboard

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

impl Debug for FakeClipboard

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FakeClipboard

Source§

fn default() -> FakeClipboard

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.