[][src]Struct arboard::Clipboard

pub struct Clipboard { /* fields omitted */ }

The OS independent struct for accessing the clipboard.

Any number of Clipboard instances are allowed to exist at a single point in time. Note however that all Clipboards must be 'dropped' before the program exits. In most scenarios this happens automatically but there are frameworks (for example winit) that take over the execution and where the objects don't get dropped when the application exits. In these cases you have to make sure the object is dropped by taking ownership of it in a confined scope when detecting that your application is about to quit.

It is also valid to have multiple Clipboards on separate threads at once but note that executing multiple clipboard operations in paralell might fail with a ClipboardOccupied error.

Implementations

impl Clipboard[src]

pub fn new() -> Result<Self, Error>[src]

Creates an instance of the clipboard

pub fn get_text(&mut self) -> Result<String, Error>[src]

Fetches utf-8 text from the clipboard and returns it.

pub fn set_text(&mut self, text: String) -> Result<(), Error>[src]

Places the text onto the clipboard. Any valid utf-8 string is accepted.

pub fn get_image(&mut self) -> Result<ImageData<'_>, Error>[src]

Fetches image data from the clipboard, and returns the decoded pixels.

Any image data placed on the clipboard with set_image will be possible read back, using this function. However it's of not guaranteed that an image placed on the clipboard by any other application will be of a supported format. This function looks for

pub fn set_image(&mut self, image: ImageData<'_>) -> Result<(), Error>[src]

Places an image to the clipboard.

The chosen output format, depending on the platform is the following:

  • On macOS: NSImage object
  • On Linux: PNG, under the atom image/png
  • On Windows: BMP, or more specifically, CF_DIB

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.