clipboard-stream 0.2.1

Async stream of clipboard change events
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use clipboard_stream::{ClipboardEventListener, Kind};
use futures::stream::TryStreamExt;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut event_lisener = ClipboardEventListener::spawn();
    let mut stream = event_lisener.new_stream(Kind::Utf8String, 32)?;

    let future = async move {
        loop {
            if let Ok(Some(body)) = stream.try_next().await {
                println!("clipboard updated: {:?}", body);
            }
        }
    };

    let _ = futures::executor::block_on(future);
    Ok(())
}