diff options
author | Stephan Dilly <dilly.stephan@gmail.com> | 2020-09-01 01:36:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-01 01:36:38 +0200 |
commit | e5c38e8d4a23d879ef1d0fb4460f2d20a7004f38 (patch) | |
tree | 52b128a28af3a7ae32c2c4f0beb1e674ee023063 /src/clipboard.rs | |
parent | 9be119a2f04da924d6c75e3bb3be6a910a80b93a (diff) |
revert clipboard feature on linux to fix static linux binary build (#261)v0.10.1
Diffstat (limited to 'src/clipboard.rs')
-rw-r--r-- | src/clipboard.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/clipboard.rs b/src/clipboard.rs new file mode 100644 index 00000000..b0c3e42f --- /dev/null +++ b/src/clipboard.rs @@ -0,0 +1,30 @@ +use anyhow::Result; +#[cfg(feature = "clipboard")] +use clipboard::{ClipboardContext, ClipboardProvider}; + +#[cfg(feature = "clipboard")] +pub fn copy_string(string: String) -> Result<()> { + use anyhow::anyhow; + + let mut ctx: ClipboardContext = ClipboardProvider::new() + .map_err(|_| anyhow!("failed to get access to clipboard"))?; + ctx.set_contents(string) + .map_err(|_| anyhow!("failed to set clipboard contents"))?; + + Ok(()) +} + +#[cfg(not(feature = "clipboard"))] +pub fn copy_string(_string: String) -> Result<()> { + Ok(()) +} + +#[cfg(feature = "clipboard")] +pub fn is_supported() -> bool { + true +} + +#[cfg(not(feature = "clipboard"))] +pub fn is_supported() -> bool { + false +} |