diff options
author | Yifei Zhan <git@zhan.science> | 2024-05-06 02:58:49 +0000 |
---|---|---|
committer | Wez Furlong <wez@wezfurlong.org> | 2024-05-05 22:20:21 -0700 |
commit | 6448220c1146a08a80e8878aef5e17948660a580 (patch) | |
tree | b87c2581728521f4698e925a607bc85753552f71 /src/deviceinfo.rs | |
parent | 7e5a230ce09183596af53cc777d64d8520492c35 (diff) |
update evdev-rs to 0.6.1
Diffstat (limited to 'src/deviceinfo.rs')
-rw-r--r-- | src/deviceinfo.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/deviceinfo.rs b/src/deviceinfo.rs index 7239294..353f105 100644 --- a/src/deviceinfo.rs +++ b/src/deviceinfo.rs @@ -1,5 +1,5 @@ -use anyhow::{anyhow, bail, Context, Result}; -use evdev_rs::Device; +use anyhow::{bail, Context, Result}; +use evdev_rs::{Device, DeviceWrapper}; use std::cmp::Ordering; use std::path::PathBuf; @@ -13,10 +13,8 @@ pub struct DeviceInfo { impl DeviceInfo { pub fn with_path(path: PathBuf) -> Result<Self> { let f = std::fs::File::open(&path).context(format!("opening {}", path.display()))?; - let mut input = Device::new().ok_or_else(|| anyhow!("failed to make new Device"))?; - input - .set_fd(f) - .context(format!("assigning fd for {} to Device", path.display()))?; + let input = Device::new_from_file(f) + .with_context(|| format!("failed to create new Device from file {}", path.display()))?; Ok(Self { name: input.name().unwrap_or("").to_string(), |