pub mod platform;
use std::{borrow::Cow, error, fmt};
pub struct ClipboardData(pub Vec<u8>, pub String);
impl AllowedMimeTypes for ClipboardData {
fn allowed() -> Cow<'static, [String]> {
Cow::Owned(vec![])
}
}
impl TryFrom<(Vec<u8>, String)> for ClipboardData {
type Error = Error;
fn try_from((data, mime): (Vec<u8>, String)) -> Result<Self, Self::Error> {
Ok(ClipboardData(data, mime))
}
}
pub struct ClipboardLoadData<T>(pub T);
pub trait AllowedMimeTypes:
TryFrom<(Vec<u8>, String)> + Send + Sync + 'static
{
fn allowed() -> Cow<'static, [String]>;
}
pub trait AsMimeTypes {
fn available(&self) -> Cow<'static, [String]>;
fn as_bytes(&self, mime_type: &str) -> Option<Cow<'static, [u8]>>;
}
impl<T: AsMimeTypes + ?Sized> AsMimeTypes for Box<T> {
fn available(&self) -> Cow<'static, [String]> {
self.as_ref().available()
}
fn as_bytes(&self, mime_type: &str) -> Option<Cow<'static, [u8]>> {
self.as_ref().as_bytes(mime_type)
}
}
pub struct ClipboardStoreData<T>(pub T);
#[derive(Debug, Clone, Copy)]
pub struct Error;
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Unsupported mime type")
}
}
impl error::Error for Error {}