espanso/src/clipboard/mod.rs
2019-09-10 18:23:27 +02:00

35 lines
832 B
Rust

#[cfg(target_os = "windows")]
mod windows;
#[cfg(target_os = "linux")]
mod linux;
#[cfg(target_os = "macos")]
mod macos;
pub trait ClipboardManager {
fn get_clipboard(&self) -> Option<String>;
fn set_clipboard(&self, payload: &str);
}
// TODO: change windows and linux implementations to avoid initialize() call and use constructor instead
// LINUX IMPLEMENTATION
#[cfg(target_os = "linux")]
pub fn get_manager() -> impl ClipboardManager {
let manager = linux::LinuxClipboardManager{};
manager.initialize();
manager
}
// WINDOWS IMPLEMENTATION
#[cfg(target_os = "windows")]
pub fn get_manager() -> impl ClipboardManager {
windows::WindowsClipboardManager::new()
}
// MAC IMPLEMENTATION
#[cfg(target_os = "macos")]
pub fn get_manager() -> impl ClipboardManager {
macos::MacClipboardManager::new()
}