Skip to main content

Clipboard

Struct Clipboard 

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

Clipboard manager for handling copy/cut/paste operations.

Implementations§

Source§

impl Clipboard

Source

pub fn new() -> Self

Create a new clipboard.

Source

pub fn unavailable() -> Self

Create an unavailable clipboard (for testing).

Source

pub fn is_available(&self) -> bool

Check if clipboard is available.

Source

pub fn write(&mut self, data: ClipboardData) -> ClipboardResult

Write data to the clipboard.

Source

pub fn write_text(&mut self, text: &str) -> ClipboardResult

Write text to the clipboard.

Source

pub fn write_html(&mut self, html: &str) -> ClipboardResult

Write HTML to the clipboard.

Source

pub fn read(&self) -> Result<ClipboardData, ClipboardResult>

Read all data from the clipboard.

Source

pub fn read_text(&self) -> Result<Option<String>, ClipboardResult>

Read text from the clipboard.

Source

pub fn read_html(&self) -> Result<Option<String>, ClipboardResult>

Read HTML from the clipboard.

Source

pub fn has_format(&self, format: &ClipboardFormat) -> bool

Check if clipboard has a specific format.

Source

pub fn available_formats(&self) -> Vec<ClipboardFormat>

Get available formats.

Source

pub fn clear(&mut self) -> ClipboardResult

Clear the clipboard.

Source

pub fn on_change(&mut self, callback: ClipboardCallback)

Add a listener for clipboard changes.

Source

pub fn listener_count(&self) -> usize

Get listener count.

Source

pub fn cut(&mut self, data: ClipboardData) -> ClipboardResult

Simulate a cut operation (copies and signals cut).

Source

pub fn signal_paste(&mut self)

Signal that a paste occurred.

Trait Implementations§

Source§

impl Debug for Clipboard

Source§

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

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

impl Default for Clipboard

Source§

fn default() -> Self

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.