File tree Expand file tree Collapse file tree 9 files changed +16
-56
lines changed
Expand file tree Collapse file tree 9 files changed +16
-56
lines changed Original file line number Diff line number Diff line change @@ -26,9 +26,6 @@ num_enum = "0.5"
2626thiserror = " 1"
2727bitflags = " 1.3.2"
2828
29- [build-dependencies ]
30- copy_to_output = " 2.0.0"
31-
3229[dev-dependencies ]
3330throbber = " 0.1"
3431image = " 0.24.2"
Original file line number Diff line number Diff line change 11use std:: { env, path:: PathBuf } ;
22
3- use copy_to_output:: copy_to_output;
4-
53fn main ( ) {
64 // Find Leap SDK
75 println ! ( r"cargo:rerun-if-env-changed=LEAPSDK_LIB_PATH" ) ;
@@ -21,13 +19,5 @@ fn main() {
2119 // Link to LeapC.lib
2220 println ! ( r"cargo:rustc-link-search={}" , path_str) ;
2321 println ! ( r"cargo:rustc-link-lib=static=LeapC" ) ;
24-
25- // Copy LeapC.dll to the output
26- let mut leapcdll_path = leapsdk_path. clone ( ) ;
27- leapcdll_path. push ( "LeapC.dll" ) ;
28- let leapcdll_path = leapcdll_path. to_str ( ) . unwrap ( ) ;
29- println ! ( "cargo:rerun-if-changed={}" , leapcdll_path) ;
30- copy_to_output ( leapcdll_path, & env:: var ( "PROFILE" ) . unwrap ( ) )
31- . expect ( "Failed to copy LeapC.dll to the output path" ) ;
3222 }
3323}
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ fn main() {
1010
1111 connection. wait_for ( "Connecting to the service..." . to_string ( ) , |e| match e {
1212 Event :: Connection ( e) => {
13- let flags = e. flags ( ) . expect ( "Invalid service state flags" ) ;
13+ let flags = e. flags ( ) ;
1414 Msg :: Success ( format ! ( "Connected. Service state: {:?}" , flags) )
1515 }
1616 _ => Msg :: None ,
Original file line number Diff line number Diff line change @@ -20,8 +20,8 @@ impl DeviceInfo {
2020 }
2121
2222 #[ doc = " A combination of eLeapDeviceStatus flags. @since 3.0.0" ]
23- pub fn status ( & self ) -> Option < DeviceStatus > {
24- DeviceStatus :: from_bits ( self . handle . status )
23+ pub fn status ( & self ) -> DeviceStatus {
24+ DeviceStatus :: from_bits_truncate ( self . handle . status )
2525 }
2626
2727 // TODO get_caps
@@ -79,6 +79,6 @@ mod tests {
7979 assert_ne ! ( device_info. pid( ) , DevicePID :: Unknown ) ;
8080 let serial = device_info. serial ( ) . expect ( "Failed to get serial" ) ;
8181 assert ! ( serial. len( ) > 0 ) ;
82- device_info . status ( ) . expect ( "Failed to get device status" ) ;
82+ let _status = device_info . status ( ) ;
8383 }
8484}
Original file line number Diff line number Diff line change @@ -12,8 +12,8 @@ crate::leap_ref_struct!(
1212
1313impl < ' a > ConnectionEvent < ' a > {
1414 #[ doc = " A combination of eLeapServiceDisposition flags. @since 3.1.3" ]
15- pub fn flags ( & self ) -> Option < ServiceState > {
16- ServiceState :: from_bits ( self . handle . flags )
15+ pub fn flags ( & self ) -> ServiceState {
16+ ServiceState :: from_bits_truncate ( self . handle . flags )
1717 }
1818}
1919
@@ -27,13 +27,12 @@ mod tests {
2727 let mut connection =
2828 Connection :: create ( ConnectionConfig :: default ( ) ) . expect ( "Failed to connect" ) ;
2929 connection. open ( ) . expect ( "Failed to open the connection" ) ;
30- let flags = connection. expect_event (
30+ let _flags = connection. expect_event (
3131 "Did not receive a connection event." . to_string ( ) ,
3232 |e| match e {
3333 Event :: Connection ( e) => Some ( e. flags ( ) ) ,
3434 _ => None ,
3535 } ,
3636 ) ;
37- flags. expect ( "Connection event with unknown flags." ) ;
3837 }
3938}
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ impl<'a> DeviceEvent<'a> {
2020 }
2121
2222 #[ doc = " The status of the connected device. A combination of flags from the eLeapDeviceStatus collection." ]
23- pub fn status ( & self ) -> Option < DeviceStatus > {
24- DeviceStatus :: from_bits ( self . handle . status )
23+ pub fn status ( & self ) -> DeviceStatus {
24+ DeviceStatus :: from_bits_truncate ( self . handle . status )
2525 }
2626}
Original file line number Diff line number Diff line change @@ -17,12 +17,12 @@ impl<'a> DeviceStatusChangeEvent<'a> {
1717 }
1818
1919 #[ doc = " The last known status of the device. This is a combination of eLeapDeviceStatus flags. @since 3.1.3" ]
20- pub fn status ( & self ) -> Option < DeviceStatus > {
21- DeviceStatus :: from_bits ( self . handle . status )
20+ pub fn status ( & self ) -> DeviceStatus {
21+ DeviceStatus :: from_bits_truncate ( self . handle . status )
2222 }
2323
2424 #[ doc = " The current status of the device. This is a combination of eLeapDeviceStatus flags. @since 3.1.3" ]
25- pub fn last_status ( & self ) -> Option < DeviceStatus > {
26- DeviceStatus :: from_bits ( self . handle . last_status )
25+ pub fn last_status ( & self ) -> DeviceStatus {
26+ DeviceStatus :: from_bits_truncate ( self . handle . last_status )
2727 }
2828}
Original file line number Diff line number Diff line change @@ -13,8 +13,8 @@ crate::leap_ref_struct!(
1313impl < ' a > PolicyEvent < ' a > {
1414 #[ doc = " A bitfield containing the policies effective at the" ]
1515 #[ doc = " time the policy event was processed. @since 3.0.0" ]
16- pub fn current_policy ( & self ) -> Option < PolicyFlags > {
17- PolicyFlags :: from_bits ( self . handle . current_policy . into ( ) )
16+ pub fn current_policy ( & self ) -> PolicyFlags {
17+ PolicyFlags :: from_bits_truncate ( self . handle . current_policy . into ( ) )
1818 }
1919}
2020
@@ -32,10 +32,7 @@ mod tests {
3232 "Did not receive an image policy event" . to_string ( ) ,
3333 |e| match e {
3434 Event :: Policy ( e) => {
35- if e. current_policy ( )
36- . expect ( "Failed to parse a policy flag" )
37- . contains ( PolicyFlags :: IMAGES )
38- {
35+ if e. current_policy ( ) . contains ( PolicyFlags :: IMAGES ) {
3936 Some ( ( ) )
4037 } else {
4138 None
You can’t perform that action at this time.
0 commit comments