a simple clipboard for complicated times
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..0c2c8d2 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,23 @@ +//! simple possibly cross platform clipboard crate +//! +//! ``` +//! clipp::copy("wow such clipboard"); +//! assert_eq!(clipp::paste(), "wow such clipboard"); +//! ``` +#![warn(clippy::pedantic)] +#![forbid(unsafe_code)] +mod providers; + +use std::{fmt::Display, sync::OnceLock}; + +static CLIP: OnceLock<providers::Board> = OnceLock::new(); + +/// Copy text to the clipboard. +pub fn copy(text: impl Display) { + CLIP.get_or_init(providers::provide).0(&format!("{text}")); +} + +/// Paste text from the clipboard. +pub fn paste() -> String { + CLIP.get_or_init(providers::provide).1() +} |