Skip to content

Commit b5403ce

Browse files
author
pierre
committed
don't autocopy the dll, truncates the bitflags
1 parent ee17548 commit b5403ce

File tree

9 files changed

+16
-56
lines changed

9 files changed

+16
-56
lines changed

Cargo.lock

Lines changed: 0 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ num_enum = "0.5"
2626
thiserror = "1"
2727
bitflags = "1.3.2"
2828

29-
[build-dependencies]
30-
copy_to_output = "2.0.0"
31-
3229
[dev-dependencies]
3330
throbber = "0.1"
3431
image = "0.24.2"

build.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use std::{env, path::PathBuf};
22

3-
use copy_to_output::copy_to_output;
4-
53
fn 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
}

examples/interactive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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,

src/device_info.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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
}

src/events/connection_event.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ crate::leap_ref_struct!(
1212

1313
impl<'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
}

src/events/device_event.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}

src/events/device_status_change_event.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff 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
}

src/events/policy_event.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ crate::leap_ref_struct!(
1313
impl<'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

0 commit comments

Comments
 (0)