Skip to content

Commit 8163ce0

Browse files
committed
Switch from libusb to rusb
1 parent 258ad5b commit 8163ce0

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ authors = ["Matti Virkkunen <mvirkkunen@gmail.com>"]
1010
repository = "https://github.com/mvirkkunen/usb-device"
1111

1212
[dev-dependencies]
13-
libusb = "0.3.0"
13+
rusb = "0.8.0"
1414
rand = "0.6.1"
1515

1616
[features]

tests/test_class_host/device.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
use std::time::Duration;
2-
use libusb::*;
2+
use rusb::*;
33
use usb_device::test_class;
44

55
pub const TIMEOUT: Duration = Duration::from_secs(1);
66
pub const EN_US: u16 = 0x0409;
77

8-
pub struct DeviceHandles<'a> {
8+
pub struct DeviceHandles {
99
pub device_descriptor: DeviceDescriptor,
1010
pub config_descriptor: ConfigDescriptor,
11-
pub handle: DeviceHandle<'a>,
11+
pub handle: DeviceHandle<Context>,
1212
pub en_us: Language,
1313
}
1414

15-
impl<'a> ::std::ops::Deref for DeviceHandles<'a> {
16-
type Target = DeviceHandle<'a>;
15+
impl ::std::ops::Deref for DeviceHandles {
16+
type Target = DeviceHandle<Context>;
1717

18-
fn deref(&self) -> &DeviceHandle<'a> {
18+
fn deref(&self) -> &DeviceHandle<Context> {
1919
&self.handle
2020
}
2121
}
2222

23-
impl<'a> ::std::ops::DerefMut for DeviceHandles<'a> {
24-
fn deref_mut(&mut self) -> &mut DeviceHandle<'a> {
23+
impl ::std::ops::DerefMut for DeviceHandles {
24+
fn deref_mut(&mut self) -> &mut DeviceHandle<Context> {
2525
&mut self.handle
2626
}
2727
}
2828

29-
pub fn open_device(ctx: &Context) -> libusb::Result<DeviceHandles<'_>> {
29+
pub fn open_device(ctx: &Context) -> rusb::Result<DeviceHandles> {
3030
for device in ctx.devices()?.iter() {
3131
let device_descriptor = device.device_descriptor()?;
3232

@@ -58,5 +58,5 @@ pub fn open_device(ctx: &Context) -> libusb::Result<DeviceHandles<'_>> {
5858
}
5959
}
6060

61-
Err(libusb::Error::NoDevice)
61+
Err(rusb::Error::NoDevice)
6262
}

tests/test_class_host/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::io::prelude::*;
1212
use std::thread;
1313
use std::time::Duration;
1414
use std::panic;
15-
use libusb::*;
15+
use rusb::*;
1616
use usb_device::device::CONFIGURATION_VALUE;
1717
use crate::device::open_device;
1818
use crate::tests::{TestFn, get_tests};
@@ -31,7 +31,7 @@ fn run_tests(tests: &[(&str, TestFn)]) {
3131
let ctx = Context::new().expect("create libusb context");
3232

3333
// Look for the device for about 5 seconds in case it hasn't finished enumerating yet
34-
let mut dev = Err(libusb::Error::NoDevice);
34+
let mut dev = Err(rusb::Error::NoDevice);
3535
for _ in 0..50 {
3636
dev = open_device(&ctx);
3737
if dev.is_ok() {

tests/test_class_host/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::cmp::max;
22
use std::fmt::Write;
33
use std::time::{Duration, Instant};
4-
use libusb::*;
4+
use rusb::*;
55
use rand::prelude::*;
66
use usb_device::test_class;
77
use crate::device::*;
@@ -16,7 +16,7 @@ macro_rules! tests {
1616
let mut tests: Vec<(&'static str, TestFn)> = Vec::new();
1717

1818
$(
19-
fn $name($dev: &mut DeviceHandles<'_>, $out: &mut String) {
19+
fn $name($dev: &mut DeviceHandles, $out: &mut String) {
2020
$body
2121
}
2222

0 commit comments

Comments
 (0)