1pub mod platform;
2
3use std::{borrow::Cow, error, fmt};
6
7pub struct ClipboardData(pub Vec<u8>, pub String);
9
10impl AllowedMimeTypes for ClipboardData {
11 fn allowed() -> Cow<'static, [String]> {
12 Cow::Owned(vec![])
13 }
14}
15
16impl TryFrom<(Vec<u8>, String)> for ClipboardData {
17 type Error = Error;
18
19 fn try_from((data, mime): (Vec<u8>, String)) -> Result<Self, Self::Error> {
20 Ok(ClipboardData(data, mime))
21 }
22}
23
24pub struct ClipboardLoadData<T>(pub T);
26
27pub trait AllowedMimeTypes:
29 TryFrom<(Vec<u8>, String)> + Send + Sync + 'static
30{
31 fn allowed() -> Cow<'static, [String]>;
36}
37
38pub trait AsMimeTypes {
40 fn available(&self) -> Cow<'static, [String]>;
42
43 fn as_bytes(&self, mime_type: &str) -> Option<Cow<'static, [u8]>>;
45}
46
47impl<T: AsMimeTypes + ?Sized> AsMimeTypes for Box<T> {
48 fn available(&self) -> Cow<'static, [String]> {
49 self.as_ref().available()
50 }
51
52 fn as_bytes(&self, mime_type: &str) -> Option<Cow<'static, [u8]>> {
53 self.as_ref().as_bytes(mime_type)
54 }
55}
56
57pub struct ClipboardStoreData<T>(pub T);
59
60#[derive(Debug, Clone, Copy)]
61pub struct Error;
62
63impl fmt::Display for Error {
64 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
65 write!(f, "Unsupported mime type")
66 }
67}
68
69impl error::Error for Error {}