Cross-platform clipboard management library powered by clip.
Features
- Read and write UTF-8 text to/from the clipboard
- Read and write RGBA images to/from the clipboard
- Clipboard clearing
Platform support
| Platform | Clear | Text (R) | Text (W) | Images (R) | Images (W) |
|---|---|---|---|---|---|
| Windows | ✅ | ✅ | ✅ | ✅ | ✅ |
| macOS | ✅ | ✅ | ✅ | ✅ | ✅ |
| Linux (X11) | ✅ | ✅ | ✅ | ✅ | ✅ |
Linux
Requires the libx11-dev/libX11-devel and libpng-dev/libpng-devel packages to be installed.
Thread Safety
Not all OS clipboard APIs are thread-safe, so whilst the functions in this crate do their best to be thread-safe by synchronising using an internal mutex, using other clipboard libraries or calling OS clipboard APIs directly may cause undefined behaviour.
Examples
Reading data
let mut clipboard = get;
match clipboard.read
Writing text
let mut clipboard = get;
clipboard.write_text.unwrap;
assert_eq!;
Writing an image
let mut clipboard = get;
let image = from_fn;
clipboard.write_image.unwrap;
let clipboard_image = clipboard.read.unwrap;
assert_eq!;