pub struct Clipboard { /* private fields */ }
Expand description
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 parallel might fail with a ClipboardOccupied
error.
Implementations
sourceimpl Clipboard
impl Clipboard
sourcepub fn get_text(&mut self) -> Result<String, Error>
pub fn get_text(&mut self) -> Result<String, Error>
Fetches utf-8 text from the clipboard and returns it.
sourcepub fn set_text(&mut self, text: String) -> Result<(), Error>
pub fn set_text(&mut self, text: String) -> Result<(), Error>
Places the text onto the clipboard. Any valid utf-8 string is accepted.
sourcepub fn get_image(&mut self) -> Result<ImageData<'static>, Error>
pub fn get_image(&mut self) -> Result<ImageData<'static>, Error>
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.
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more