1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
mod clipboard;
mod error;

pub use xcb::*;

use std::error::Error;

pub struct Clipboard(clipboard::Clipboard);

impl Clipboard {
    pub fn new() -> Result<Clipboard, Box<dyn Error>> {
        Ok(Clipboard(clipboard::Clipboard::new()?))
    }

    pub fn read(&self) -> Result<String, Box<dyn Error>> {
        Ok(String::from_utf8(self.0.load(
            self.0.getter.atoms.clipboard,
            self.0.getter.atoms.utf8_string,
            self.0.getter.atoms.property,
            std::time::Duration::from_secs(3),
        )?)?)
    }
}