Struct clipboard_rs::ClipboardWatcherContext
source · pub struct ClipboardWatcherContext { /* private fields */ }Implementations§
source§impl ClipboardWatcherContext
impl ClipboardWatcherContext
sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Examples found in repository?
examples/watch_change.rs (line 6)
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
fn main() {
let ctx = ClipboardContext::new().unwrap();
let mut watcher = ClipboardWatcherContext::new().unwrap();
watcher.add_handler(Box::new(move || {
let content = ctx.get_text().unwrap();
println!("read:{}", content);
}));
let watcher_shutdown = watcher.get_shutdown_channel();
thread::spawn(move || {
thread::sleep(Duration::from_secs(5));
println!("stop watch!");
watcher_shutdown.stop();
});
println!("start watch!");
watcher.start_watch();
}Trait Implementations§
source§impl ClipboardWatcher for ClipboardWatcherContext
impl ClipboardWatcher for ClipboardWatcherContext
fn add_handler(&mut self, f: CallBack) -> &mut Self
fn start_watch(&mut self)
fn get_shutdown_channel(&self) -> WatcherShutdown
Auto Trait Implementations§
impl !RefUnwindSafe for ClipboardWatcherContext
impl Send for ClipboardWatcherContext
impl !Sync for ClipboardWatcherContext
impl Unpin for ClipboardWatcherContext
impl !UnwindSafe for ClipboardWatcherContext
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