mod combined;
pub mod display;
#[cfg(feature = "osc52")]
pub mod osc52;
#[cfg(all(
feature = "wayland-bin",
unix,
not(any(target_os = "macos", target_os = "android", target_os = "emscripten"))
))]
pub mod wayland_bin;
#[cfg(all(
feature = "x11-bin",
unix,
not(any(target_os = "macos", target_os = "android", target_os = "emscripten"))
))]
pub mod x11_bin;
#[cfg(all(
feature = "x11-fork",
unix,
not(any(target_os = "macos", target_os = "android", target_os = "emscripten"))
))]
pub mod x11_fork;
#[cfg(not(all(
feature = "wayland-bin",
unix,
not(any(target_os = "macos", target_os = "android", target_os = "emscripten"))
)))]
pub mod wayland_bin {
pub type ClipboardContext = copypasta::ClipboardContext;
}
#[cfg(not(all(
feature = "x11-bin",
unix,
not(any(target_os = "macos", target_os = "android", target_os = "emscripten"))
)))]
pub mod x11_bin {
pub type ClipboardContext = copypasta::ClipboardContext;
}
#[cfg(not(all(
feature = "x11-fork",
unix,
not(any(target_os = "macos", target_os = "android", target_os = "emscripten"))
)))]
pub mod x11_fork {
pub type ClipboardContext = copypasta::ClipboardContext;
}
use std::error::Error;
pub type ClipResult<T> = Result<T, Box<dyn Error + Send + Sync + 'static>>;
pub use combined::CombinedClipboardContext;
pub use copypasta;
pub fn try_context() -> Option<Box<dyn ClipboardProviderExt>> {
display::DisplayServer::select().try_context()
}
pub mod prelude {
pub use super::copypasta::ClipboardProvider;
pub use super::ClipboardProviderExt;
}
pub trait ClipboardProviderExt: prelude::ClipboardProvider {
fn display_server(&self) -> Option<display::DisplayServer>;
fn has_bin_lifetime(&self) -> bool {
false
}
}
impl ClipboardProviderExt for copypasta::nop_clipboard::NopClipboardContext {
fn display_server(&self) -> Option<display::DisplayServer> {
None
}
fn has_bin_lifetime(&self) -> bool {
false
}
}
#[cfg(all(
unix,
not(any(
target_os = "macos",
target_os = "android",
target_os = "ios",
target_os = "emscripten"
))
))]
impl ClipboardProviderExt for copypasta::x11_clipboard::X11ClipboardContext {
fn display_server(&self) -> Option<display::DisplayServer> {
Some(display::DisplayServer::X11)
}
fn has_bin_lifetime(&self) -> bool {
true
}
}
#[cfg(all(
unix,
not(any(
target_os = "macos",
target_os = "android",
target_os = "ios",
target_os = "emscripten"
))
))]
impl ClipboardProviderExt for copypasta::wayland_clipboard::Clipboard {
fn display_server(&self) -> Option<display::DisplayServer> {
Some(display::DisplayServer::Wayland)
}
fn has_bin_lifetime(&self) -> bool {
true
}
}
#[cfg(windows)]
impl ClipboardProviderExt for copypasta::windows_clipboard::WindowsClipboardContext {
fn display_server(&self) -> Option<display::DisplayServer> {
Some(display::DisplayServer::Windows)
}
fn has_bin_lifetime(&self) -> bool {
false
}
}
#[cfg(target_os = "macos")]
impl ClipboardProviderExt for copypasta::osx_clipboard::OSXClipboardContext {
fn display_server(&self) -> Option<display::DisplayServer> {
Some(display::DisplayServer::MacOs)
}
fn has_bin_lifetime(&self) -> bool {
false
}
}