[−][src]Struct arboard::Clipboard
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 Clipboard
s 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
impl RefUnwindSafe for Clipboard
impl Send for Clipboard
impl Sync for Clipboard
impl Unpin for Clipboard
impl UnwindSafe for Clipboard
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,