• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

examples/H03-May-2022-3322

src/H03-May-2022-331188

.cargo-checksum.jsonH A D03-May-202289 11

.gitignoreH A D19-Sep-201818 32

.travis.ymlH A D19-Sep-2018249 1613

Cargo.tomlH A D01-Jan-19701.3 KiB3329

Cargo.toml.orig-cargoH A D19-Sep-2018616 2016

LICENSE.apache2H A D19-Sep-201811.1 KiB201169

LICENSE.mitH A D19-Sep-20181 KiB2622

README.mdH A D19-Sep-20181.6 KiB4933

appveyor.ymlH A D19-Sep-20184.1 KiB122105

README.md

1# rust-clipboard
2
3rust-clipboard is a cross-platform library for getting and setting the contents of the OS-level clipboard.
4It has been tested on Windows, Mac OSX, GNU/Linux, and FreeBSD.
5It is used in Mozilla Servo.
6
7[![](http://meritbadge.herokuapp.com/clipboard)](https://crates.io/crates/clipboard)
8[![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/github/aweinstock314/rust-clipboard)](https://ci.appveyor.com/project/aweinstock314/rust-clipboard)
9[![Travis Build Status](https://travis-ci.org/aweinstock314/rust-clipboard.svg?branch=master)](https://travis-ci.org/aweinstock314/rust-clipboard)
10
11## Prerequisites
12
13On Linux you need the x11 library, install it with something like:
14
15```bash
16sudo apt-get install xorg-dev
17```
18
19## Example
20
21```rust
22extern crate clipboard;
23
24use clipboard::ClipboardProvider;
25use clipboard::ClipboardContext;
26
27fn example() {
28    let mut ctx: ClipboardContext = ClipboardProvider::new().unwrap();
29    println!("{:?}", ctx.get_contents());
30    ctx.set_contents("some string".to_owned()).unwrap();
31}
32```
33
34## API
35
36The `ClipboardProvider` trait has the following functions:
37
38```rust
39fn new() -> Result<Self, Box<Error>>;
40fn get_contents(&mut self) -> Result<String, Box<Error>>;
41fn set_contents(&mut self, String) -> Result<(), Box<Error>>;
42```
43
44`ClipboardContext` is a type alias for one of {`WindowsClipboardContext`, `OSXClipboardContext`, `X11ClipboardContext`, `NopClipboardContext`}, all of which implement `ClipboardProvider`. Which concrete type is chosen for `ClipboardContext` depends on the OS (via conditional compilation).
45
46## License
47
48`rust-clipboard` is dual-licensed under MIT and Apache2.
49