1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#![allow(dead_code)]
use crate::{SysResult, Getter, Setter};
use winapi::um::winuser;
pub const CF_BITMAP: u32 = winuser::CF_BITMAP;
pub const CF_DIB: u32 = winuser::CF_DIB;
pub const CF_DIBV5: u32 = winuser::CF_DIBV5;
pub const CF_DIF: u32 = winuser::CF_DIF;
pub const CF_DSPBITMAP: u32 = winuser::CF_DSPBITMAP;
pub const CF_DSPENHMETAFILE: u32 = winuser::CF_DSPENHMETAFILE;
pub const CF_DSPMETAFILEPICT: u32 = winuser::CF_DSPMETAFILEPICT;
pub const CF_DSPTEXT: u32 = winuser::CF_DSPTEXT;
pub const CF_ENHMETAFILE: u32 = winuser::CF_ENHMETAFILE;
pub const CF_GDIOBJFIRST: u32 = winuser::CF_GDIOBJFIRST;
pub const CF_GDIOBJLAST: u32 = winuser::CF_GDIOBJLAST;
pub const CF_HDROP: u32 = winuser::CF_HDROP;
pub const CF_LOCALE: u32 = winuser::CF_LOCALE;
pub const CF_METAFILEPICT: u32 = winuser::CF_METAFILEPICT;
pub const CF_OEMTEXT: u32 = winuser::CF_OEMTEXT;
pub const CF_OWNERDISPLAY: u32 = winuser::CF_OWNERDISPLAY;
pub const CF_PALETTE: u32 = winuser::CF_PALETTE;
pub const CF_PENDATA: u32 = winuser::CF_PENDATA;
pub const CF_PRIVATEFIRST: u32 = winuser::CF_PRIVATEFIRST;
pub const CF_PRIVATELAST: u32 = winuser::CF_PRIVATELAST;
pub const CF_RIFF: u32 = winuser::CF_RIFF;
pub const CF_SYLK: u32 = winuser::CF_SYLK;
pub const CF_TEXT: u32 = winuser::CF_TEXT;
pub const CF_TIFF: u32 = winuser::CF_TIFF;
pub const CF_UNICODETEXT: u32 = winuser::CF_UNICODETEXT;
pub const CF_WAVE: u32 = winuser::CF_WAVE;
pub struct RawData(pub u32);
impl<T: AsRef<[u8]>> Setter<T> for RawData {
#[inline(always)]
fn write_clipboard(&self, data: &T) -> SysResult<()> {
crate::raw::set(self.0, data.as_ref())
}
}
impl Getter<alloc::vec::Vec<u8>> for RawData {
#[inline(always)]
fn read_clipboard(&self, out: &mut alloc::vec::Vec<u8>) -> SysResult<usize> {
crate::raw::get_vec(self.0, out)
}
}
pub struct Unicode;
impl Getter<alloc::vec::Vec<u8>> for Unicode {
#[inline(always)]
fn read_clipboard(&self, out: &mut alloc::vec::Vec<u8>) -> SysResult<usize> {
crate::raw::get_string(out)
}
}
impl Getter<alloc::string::String> for Unicode {
#[inline(always)]
fn read_clipboard(&self, out: &mut alloc::string::String) -> SysResult<usize> {
self.read_clipboard(unsafe { out.as_mut_vec() })
}
}
impl<T: AsRef<str>> Setter<T> for Unicode {
#[inline(always)]
fn write_clipboard(&self, data: &T) -> SysResult<()> {
crate::raw::set_string(data.as_ref())
}
}
pub struct FileList;
impl Getter<alloc::vec::Vec<alloc::string::String>> for FileList {
#[inline(always)]
fn read_clipboard(&self, out: &mut alloc::vec::Vec<alloc::string::String>) -> SysResult<usize> {
crate::raw::get_file_list(out)
}
}
#[cfg(feature = "std")]
impl Getter<alloc::vec::Vec<std::path::PathBuf>> for FileList {
#[inline(always)]
fn read_clipboard(&self, out: &mut alloc::vec::Vec<std::path::PathBuf>) -> SysResult<usize> {
crate::raw::get_file_list_path(out)
}
}
impl<T: AsRef<str>> Setter<[T]> for FileList {
#[inline(always)]
fn write_clipboard(&self, data: &[T]) -> SysResult<()> {
crate::raw::set_file_list(data)
}
}
pub struct Bitmap;
impl Getter<alloc::vec::Vec<u8>> for Bitmap {
#[inline(always)]
fn read_clipboard(&self, out: &mut alloc::vec::Vec<u8>) -> SysResult<usize> {
crate::raw::get_bitmap(out)
}
}
impl<T: AsRef<[u8]>> Setter<T> for Bitmap {
#[inline(always)]
fn write_clipboard(&self, data: &T) -> SysResult<()> {
crate::raw::set_bitmap(data.as_ref())
}
}