Merge pull request #1 from simlay/ios-unimplemented-stub

This is a stub of the iOS clipboard logic.
This commit is contained in:
Héctor Ramón 2020-03-06 03:38:24 +01:00 committed by GitHub
commit 8161059964
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 0 deletions

View file

@ -2,6 +2,7 @@
unix,
not(any(
target_os = "macos",
target_os = "ios",
target_os = "android",
target_os = "emscripten"
))
@ -12,6 +13,7 @@ mod platform;
#[cfg(not(all(
unix,
not(any(
target_os = "ios",
target_os = "macos",
target_os = "android",
target_os = "emscripten"

View file

@ -15,6 +15,11 @@ pub fn new_clipboard<W: HasRawWindowHandle>(
{
Ok(Box::new(clipboard_macos::Clipboard::new()?))
}
#[cfg(target_os = "ios")]
{
Ok(Box::new(clipboard_ios::Clipboard::new()?))
}
}
#[cfg(target_os = "windows")]
@ -30,3 +35,33 @@ impl ClipboardProvider for clipboard_macos::Clipboard {
self.read()
}
}
#[cfg(target_os = "ios")]
mod clipboard_ios {
use std::error::Error;
pub struct Clipboard;
impl Clipboard {
pub fn new() -> Result<Clipboard, Box<dyn Error>> {
Ok(Self)
}
}
#[derive(Debug)]
#[allow(non_camel_case_types)]
pub enum iOSClipboardError {
Unimplemented,
}
impl std::fmt::Display for iOSClipboardError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Unimplemented")
}
}
impl Error for iOSClipboardError { }
}
#[cfg(target_os = "ios")]
impl ClipboardProvider for clipboard_ios::Clipboard {
fn read(&self) -> Result<String, Box<dyn Error>> {
Err(Box::new(clipboard_ios::iOSClipboardError::Unimplemented))
}
}