pub struct WaylandClipboardContext { /* private fields */ }
Expand description
Interface to the clipboard for Wayland windowing systems.
Other users of the Wayland clipboard will only see the contents copied to the clipboard so long as the process copying to the clipboard exists. If you need the contents of the clipboard to remain after your application shuts down, consider daemonizing the clipboard components of your application.
WaylandClipboardContext
automatically detects support for and
uses the primary selection protocol.
Example
use cli_clipboard::ClipboardProvider;
let mut clipboard = cli_clipboard::wayland_clipboard::WaylandClipboardContext::new().unwrap();
clipboard.set_contents("foo bar baz".to_string()).unwrap();
let contents = clipboard.get_contents().unwrap();
assert_eq!(contents, "foo bar baz");
Trait Implementations§
source§impl ClipboardProvider for WaylandClipboardContext
impl ClipboardProvider for WaylandClipboardContext
source§fn new() -> Result<WaylandClipboardContext, Box<dyn Error>>
fn new() -> Result<WaylandClipboardContext, Box<dyn Error>>
Constructs a new WaylandClipboardContext
that operates on all
seats using the data-control clipboard protocol. This is
intended for CLI applications that do not create Wayland
windows.
Attempts to detect whether the primary selection is supported. Assumes no primary selection support if no seats are available. In addition to returning Err on communication errors (such as when operating in an X11 environment), will also return Err if the compositor does not support the data-control protocol.
source§fn get_contents(&mut self) -> Result<String, Box<dyn Error>>
fn get_contents(&mut self) -> Result<String, Box<dyn Error>>
Pastes from the Wayland clipboard.
If the Wayland environment supported the primary selection when this context was constructed, first checks the primary selection. If pasting from the primary selection raises an error or the primary selection is unsupported, falls back to the regular clipboard.
An empty clipboard is not considered an error, but the clipboard must indicate a text MIME type and the contained text must be valid UTF-8.
source§fn set_contents(&mut self, data: String) -> Result<(), Box<dyn Error>>
fn set_contents(&mut self, data: String) -> Result<(), Box<dyn Error>>
Copies to the Wayland clipboard.
If the Wayland environment supported the primary selection when this context was constructed, this will copy to both the primary selection and the regular clipboard. Otherwise, only the regular clipboard will be pasted to.
Auto Trait Implementations§
impl RefUnwindSafe for WaylandClipboardContext
impl Send for WaylandClipboardContext
impl Sync for WaylandClipboardContext
impl Unpin for WaylandClipboardContext
impl UnwindSafe for WaylandClipboardContext
Blanket Implementations§
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more