Add dummy platform 🌮
This commit is contained in:
parent
fc11e948eb
commit
0f74d59198
7 changed files with 106 additions and 16 deletions
18
src/lib.rs
18
src/lib.rs
|
|
@ -26,6 +26,24 @@ mod platform;
|
|||
#[path = "platform/android.rs"]
|
||||
mod platform;
|
||||
|
||||
#[cfg(not(any(
|
||||
all(
|
||||
unix,
|
||||
not(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "android",
|
||||
target_os = "emscripten"
|
||||
))
|
||||
),
|
||||
target_os = "windows",
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "android"
|
||||
)))]
|
||||
#[path = "platform/dummy.rs"]
|
||||
mod platform;
|
||||
|
||||
use raw_window_handle::HasRawWindowHandle;
|
||||
use std::error::Error;
|
||||
|
||||
|
|
|
|||
23
src/platform/dummy.rs
Normal file
23
src/platform/dummy.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
use crate::ClipboardProvider;
|
||||
|
||||
use raw_window_handle::HasRawWindowHandle;
|
||||
use std::error::Error;
|
||||
|
||||
pub use clipboard_dummy as dummy;
|
||||
|
||||
pub fn connect<W: HasRawWindowHandle>(
|
||||
window: &W,
|
||||
) -> Result<Box<dyn ClipboardProvider>, Box<dyn Error>> {
|
||||
let clipboard = Box::new(dummy::Clipboard::connect()?);
|
||||
Ok(clipboard)
|
||||
}
|
||||
|
||||
impl ClipboardProvider for dummy::Clipboard {
|
||||
fn read(&self) -> Result<String, Box<dyn Error>> {
|
||||
self.read()
|
||||
}
|
||||
|
||||
fn write(&mut self, contents: String) -> Result<(), Box<dyn Error>> {
|
||||
self.write(contents)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue