@@ -6,7 +6,7 @@ mod extension;
66mod input;
77mod session;
88
9- pub use clipboard:: { ClipboardContent , ClipboardTransaction } ;
9+ pub use clipboard:: { ClipboardData , ClipboardItem } ;
1010pub use cursor:: CursorStyle ;
1111pub use desktop_size:: DesktopSize ;
1212pub use error:: { IronError , IronErrorKind } ;
@@ -20,8 +20,8 @@ pub trait RemoteDesktopApi {
2020 type SessionTerminationInfo : SessionTerminationInfo ;
2121 type DeviceEvent : DeviceEvent ;
2222 type InputTransaction : InputTransaction ;
23- type ClipboardTransaction : ClipboardTransaction ;
24- type ClipboardContent : ClipboardContent ;
23+ type ClipboardData : ClipboardData ;
24+ type ClipboardItem : ClipboardItem ;
2525 type Error : IronError ;
2626
2727 /// Called before the logger is set.
@@ -38,8 +38,8 @@ macro_rules! export {
3838 use wasm_bindgen:: prelude:: * ;
3939 use web_sys:: { js_sys, HtmlCanvasElement } ;
4040 use $crate:: {
41- ClipboardContent as _, ClipboardTransaction as _, DeviceEvent as _, InputTransaction as _,
42- IronError as _ , RemoteDesktopApi , Session as _, SessionBuilder as _, SessionTerminationInfo as _,
41+ ClipboardData as _, ClipboardItem as _, DeviceEvent as _, InputTransaction as _ , IronError as _,
42+ RemoteDesktopApi , Session as _, SessionBuilder as _, SessionTerminationInfo as _,
4343 } ;
4444
4545 #[ wasm_bindgen]
@@ -52,6 +52,12 @@ macro_rules! export {
5252 #[ wasm_bindgen]
5353 pub struct DeviceEvent ( <$api as RemoteDesktopApi >:: DeviceEvent ) ;
5454
55+ impl From <<$api as RemoteDesktopApi >:: DeviceEvent > for DeviceEvent {
56+ fn from( value: <$api as RemoteDesktopApi >:: DeviceEvent ) -> Self {
57+ Self ( value)
58+ }
59+ }
60+
5561 #[ wasm_bindgen]
5662 impl DeviceEvent {
5763 pub fn mouse_button_pressed( button: u8 ) -> Self {
@@ -101,6 +107,12 @@ macro_rules! export {
101107 #[ wasm_bindgen]
102108 pub struct InputTransaction ( <$api as RemoteDesktopApi >:: InputTransaction ) ;
103109
110+ impl From <<$api as RemoteDesktopApi >:: InputTransaction > for InputTransaction {
111+ fn from( value: <$api as RemoteDesktopApi >:: InputTransaction ) -> Self {
112+ Self ( value)
113+ }
114+ }
115+
104116 #[ wasm_bindgen]
105117 impl InputTransaction {
106118 pub fn init( ) -> Self {
@@ -115,6 +127,12 @@ macro_rules! export {
115127 #[ wasm_bindgen]
116128 pub struct IronError ( <$api as RemoteDesktopApi >:: Error ) ;
117129
130+ impl From <<$api as RemoteDesktopApi >:: Error > for IronError {
131+ fn from( value: <$api as RemoteDesktopApi >:: Error ) -> Self {
132+ Self ( value)
133+ }
134+ }
135+
118136 #[ wasm_bindgen]
119137 impl IronError {
120138 pub fn backtrace( & self ) -> String {
@@ -129,6 +147,12 @@ macro_rules! export {
129147 #[ wasm_bindgen]
130148 pub struct Session ( <$api as RemoteDesktopApi >:: Session ) ;
131149
150+ impl From <<$api as RemoteDesktopApi >:: Session > for Session {
151+ fn from( value: <$api as RemoteDesktopApi >:: Session ) -> Self {
152+ Self ( value)
153+ }
154+ }
155+
132156 #[ wasm_bindgen]
133157 impl Session {
134158 pub async fn run( & self ) -> Result <SessionTerminationInfo , IronError > {
@@ -163,7 +187,7 @@ macro_rules! export {
163187 self . 0 . shutdown( ) . map_err( IronError )
164188 }
165189
166- pub async fn on_clipboard_paste( & self , content: ClipboardTransaction ) -> Result <( ) , IronError > {
190+ pub async fn on_clipboard_paste( & self , content: ClipboardData ) -> Result <( ) , IronError > {
167191 self . 0 . on_clipboard_paste( content. 0 ) . await . map_err( IronError )
168192 }
169193
@@ -191,6 +215,12 @@ macro_rules! export {
191215 #[ wasm_bindgen]
192216 pub struct SessionBuilder ( <$api as RemoteDesktopApi >:: SessionBuilder ) ;
193217
218+ impl From <<$api as RemoteDesktopApi >:: SessionBuilder > for SessionBuilder {
219+ fn from( value: <$api as RemoteDesktopApi >:: SessionBuilder ) -> Self {
220+ Self ( value)
221+ }
222+ }
223+
194224 #[ wasm_bindgen]
195225 impl SessionBuilder {
196226 pub fn init( ) -> Self {
@@ -261,6 +291,12 @@ macro_rules! export {
261291 #[ wasm_bindgen]
262292 pub struct SessionTerminationInfo ( <$api as RemoteDesktopApi >:: SessionTerminationInfo ) ;
263293
294+ impl From <<$api as RemoteDesktopApi >:: SessionTerminationInfo > for SessionTerminationInfo {
295+ fn from( value: <$api as RemoteDesktopApi >:: SessionTerminationInfo ) -> Self {
296+ Self ( value)
297+ }
298+ }
299+
264300 #[ wasm_bindgen]
265301 impl SessionTerminationInfo {
266302 pub fn reason( & self ) -> String {
@@ -269,50 +305,54 @@ macro_rules! export {
269305 }
270306
271307 #[ wasm_bindgen]
272- pub struct ClipboardTransaction ( <$api as RemoteDesktopApi >:: ClipboardTransaction ) ;
308+ pub struct ClipboardData ( <$api as RemoteDesktopApi >:: ClipboardData ) ;
309+
310+ impl From <<$api as RemoteDesktopApi >:: ClipboardData > for ClipboardData {
311+ fn from( value: <$api as RemoteDesktopApi >:: ClipboardData ) -> Self {
312+ Self ( value)
313+ }
314+ }
273315
274316 #[ wasm_bindgen]
275- impl ClipboardTransaction {
317+ impl ClipboardData {
276318 pub fn init( ) -> Self {
277- Self ( <<$api as RemoteDesktopApi >:: ClipboardTransaction >:: init( ) )
319+ Self ( <<$api as RemoteDesktopApi >:: ClipboardData >:: init( ) )
278320 }
279321
280- pub fn add_content ( & mut self , content : ClipboardContent ) {
281- self . 0 . add_content ( content . 0 ) ;
322+ pub fn add_text ( & mut self , mime_type : & str , text : & str ) {
323+ self . 0 . add_text ( mime_type , text ) ;
282324 }
283325
284- pub fn is_empty ( & self ) -> bool {
285- self . 0 . is_empty ( )
326+ pub fn add_binary ( & mut self , mime_type : & str , binary : & [ u8 ] ) {
327+ self . 0 . add_binary ( mime_type , binary ) ;
286328 }
287329
288- pub fn content ( & self ) -> js_sys :: Array {
289- iron_remote_desktop :: ClipboardTransaction :: contents ( & self . 0 )
330+ pub fn items ( & self ) -> Vec < ClipboardItem > {
331+ self . 0 . items ( ) . into_iter ( ) . cloned ( ) . map ( ClipboardItem ) . collect ( )
290332 }
291- }
292333
293- #[ wasm_bindgen]
294- pub struct ClipboardContent ( <$api as RemoteDesktopApi >:: ClipboardContent ) ;
334+ pub fn is_empty( & self ) -> bool {
335+ self . 0 . is_empty( )
336+ }
337+ }
295338
296339 #[ wasm_bindgen]
297- impl ClipboardContent {
298- pub fn new_text( mime_type: & str , text: & str ) -> Self {
299- Self ( <<$api as RemoteDesktopApi >:: ClipboardContent >:: new_text(
300- mime_type, text,
301- ) )
302- }
340+ pub struct ClipboardItem ( <$api as RemoteDesktopApi >:: ClipboardItem ) ;
303341
304- pub fn new_binary( mime_type: & str , binary: & [ u8 ] ) -> Self {
305- Self ( <<$api as RemoteDesktopApi >:: ClipboardContent >:: new_binary(
306- mime_type, binary,
307- ) )
342+ impl From <<$api as RemoteDesktopApi >:: ClipboardItem > for ClipboardItem {
343+ fn from( value: <$api as RemoteDesktopApi >:: ClipboardItem ) -> Self {
344+ Self ( value)
308345 }
346+ }
309347
348+ #[ wasm_bindgen]
349+ impl ClipboardItem {
310350 pub fn mime_type( & self ) -> String {
311351 self . 0 . mime_type( ) . to_owned( )
312352 }
313353
314354 pub fn value( & self ) -> JsValue {
315- iron_remote_desktop :: ClipboardContent :: value ( & self . 0 )
355+ self . 0 . value ( ) . into ( )
316356 }
317357 }
318358 }
0 commit comments