1- use std:: { ffi:: CString , mem} ;
1+ use std:: { ffi:: CString , marker :: PhantomData , mem} ;
22
33use :: leap_sys:: * ;
44
@@ -9,10 +9,6 @@ use crate::*;
99#[ doc = " @since 3.0.0" ]
1010pub struct Connection {
1111 handle : LEAP_CONNECTION ,
12- // Each call to call() invalidates the connection message pointer,
13- // and it is distroy on the connection drop.
14- // Only distribute non mutable references of this one.
15- connection_message : Option < ConnectionMessage > ,
1612}
1713
1814impl Drop for Connection {
@@ -45,7 +41,6 @@ impl Connection {
4541
4642 Ok ( Self {
4743 handle : leap_connection,
48- connection_message : None ,
4944 } )
5045 }
5146
@@ -97,17 +92,13 @@ impl Connection {
9792 #[ doc = " times out, this method will return eLeapRS_Timeout. The evt pointer will reference a" ]
9893 #[ doc = " message of type eLeapEventType_None." ]
9994 #[ doc = " @since 3.0.0" ]
100- pub fn poll ( & mut self , timeout : u32 ) -> Result < & ConnectionMessage , Error > {
101- // The code after will invalidate it.
102- self . connection_message = None ;
95+ pub fn poll ( & mut self , timeout : u32 ) -> Result < ConnectionMessage , Error > {
10396 let mut msg: LEAP_CONNECTION_MESSAGE ;
10497 unsafe {
10598 msg = mem:: zeroed ( ) ;
10699 leap_try ( LeapPollConnection ( self . handle , timeout, & mut msg) ) ?;
107100 }
108- self . connection_message = Some ( ConnectionMessage ( msg) ) ;
109-
110- Ok ( self . connection_message . as_ref ( ) . unwrap ( ) )
101+ Ok ( ConnectionMessage ( msg, PhantomData ) )
111102 }
112103
113104 #[ doc = " Retrieves a list of Ultraleap Tracking camera devices currently attached to the system." ]
0 commit comments