src/global/functions/clipboard.rs
13 lines · 426 bytes
2 symbols in this file
1use clipboard::{ClipboardContext, ClipboardProvider};
2
3/// get the clipboard content
4pub fn get_clipboard() -> String {
5 let mut ctx: ClipboardContext = ClipboardProvider::new().unwrap();
6 ctx.get_contents().unwrap_or_default()
7}
8
9/// set the clipboard content, panics if failed
10pub fn set_clipboard(s: String) {
11 let mut ctx: ClipboardContext = ClipboardProvider::new().unwrap();
12 ctx.set_contents(s).unwrap();
13}