pub struct WlClipboardCopyStream { /* private fields */ }
Expand description
copy stream, it can used to make a wl-copy
Implementations§
source§impl WlClipboardCopyStream
impl WlClipboardCopyStream
sourcepub fn init() -> Result<Self, WlClipboardListenerError>
pub fn init() -> Result<Self, WlClipboardListenerError>
init a copy steam, you can use it to copy some files
sourcepub fn copy_to_clipboard(
&mut self,
data: Vec<u8>,
mimetypes: Vec<&str>,
useprimary: bool
) -> Result<(), WlClipboardListenerError>
pub fn copy_to_clipboard( &mut self, data: Vec<u8>, mimetypes: Vec<&str>, useprimary: bool ) -> Result<(), WlClipboardListenerError>
it will run a never end loop, to handle the paste event, like what wl-copy do it will live until next copy event happened you need to pass data and if use useprimary to it, if is useprimary, you can use the middle button of mouse to paste Take primary-selection as reference
use wayland_clipboard_listener::{WlClipboardCopyStream, WlClipboardListenerError};
let args = std::env::args();
if args.len() != 2 {
println!("You need to pass a string to it");
} else {
let context: &str = &args.last().unwrap();
let mut stream = WlClipboardCopyStream::init().unwrap();
stream.copy_to_clipboard(context.as_bytes().to_vec(), vec!["STRING"], false).unwrap();
}
Auto Trait Implementations§
impl !RefUnwindSafe for WlClipboardCopyStream
impl Send for WlClipboardCopyStream
impl Sync for WlClipboardCopyStream
impl Unpin for WlClipboardCopyStream
impl !UnwindSafe for WlClipboardCopyStream
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
Convert
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
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.