#clipboard

copypasta

copypasta is a cross-platform library for getting and setting the contents of the OS-level clipboard

10 releases

0.8.2 Feb 17, 2023
0.8.1 Jun 18, 2022
0.7.1 Oct 3, 2020
0.7.0 May 20, 2020
0.0.1 Oct 8, 2016

#16 in Configuration

Download history 5605/week @ 2022-11-29 5198/week @ 2022-12-06 4817/week @ 2022-12-13 5175/week @ 2022-12-20 4236/week @ 2022-12-27 4109/week @ 2023-01-03 4732/week @ 2023-01-10 4495/week @ 2023-01-17 5179/week @ 2023-01-24 6071/week @ 2023-01-31 4690/week @ 2023-02-07 6275/week @ 2023-02-14 6066/week @ 2023-02-21 5457/week @ 2023-02-28 6214/week @ 2023-03-07 4727/week @ 2023-03-14

23,553 downloads per month
Used in 126 crates (45 directly)

MIT/Apache

16KB
234 lines

copypasta

copypasta is a rust-clipboard fork, adding support for the Wayland clipboard.

rust-clipboard is a cross-platform library for getting and setting the contents of the OS-level clipboard.

Example

extern crate copypasta;

use copypasta::{ClipboardContext, ClipboardProvider};

fn main() {
    let mut ctx = ClipboardContext::new().unwrap();

    let msg = "Hello, world!";
    ctx.set_contents(msg.to_owned()).unwrap();

    let content = ctx.get_contents().unwrap();

    println!("{}", content);
}

API

The ClipboardProvider trait has the following functions:

fn get_contents(&mut self) -> Result<String, Box<Error>>;
fn set_contents(&mut self, String) -> Result<(), Box<Error>>;

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).

License

rust-clipboard is dual-licensed under MIT and Apache2.

Dependencies

~0–1.6MB
~34K SLoC