enumerate should return a tuple, (PathBuf, Device)
This commit is contained in:
parent
4d957a4dac
commit
07095dbbbc
2 changed files with 8 additions and 7 deletions
|
@ -87,6 +87,7 @@ pub mod uinput;
|
||||||
mod tokio_stream;
|
mod tokio_stream;
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::path::PathBuf;
|
||||||
use std::time::{Duration, SystemTime};
|
use std::time::{Duration, SystemTime};
|
||||||
|
|
||||||
// pub use crate::constants::FFEffect::*;
|
// pub use crate::constants::FFEffect::*;
|
||||||
|
@ -249,9 +250,9 @@ pub struct EnumerateDevices {
|
||||||
inner: raw_stream::EnumerateDevices,
|
inner: raw_stream::EnumerateDevices,
|
||||||
}
|
}
|
||||||
impl Iterator for EnumerateDevices {
|
impl Iterator for EnumerateDevices {
|
||||||
type Item = Device;
|
type Item = (PathBuf, Device);
|
||||||
fn next(&mut self) -> Option<Device> {
|
fn next(&mut self) -> Option<(PathBuf, Device)> {
|
||||||
self.inner.next().map(Device::from_raw_device)
|
self.inner.next().map(|(pb, dev)| (pb, Device::from_raw_device(dev)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::fs::{File, OpenOptions};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::mem::MaybeUninit;
|
use std::mem::MaybeUninit;
|
||||||
use std::os::unix::io::{AsRawFd, RawFd};
|
use std::os::unix::io::{AsRawFd, RawFd};
|
||||||
use std::path::Path;
|
use std::path::{Path, PathBuf};
|
||||||
use std::{io, mem};
|
use std::{io, mem};
|
||||||
|
|
||||||
use crate::constants::*;
|
use crate::constants::*;
|
||||||
|
@ -656,8 +656,8 @@ pub struct EnumerateDevices {
|
||||||
readdir: Option<std::fs::ReadDir>,
|
readdir: Option<std::fs::ReadDir>,
|
||||||
}
|
}
|
||||||
impl Iterator for EnumerateDevices {
|
impl Iterator for EnumerateDevices {
|
||||||
type Item = RawDevice;
|
type Item = (PathBuf, RawDevice);
|
||||||
fn next(&mut self) -> Option<RawDevice> {
|
fn next(&mut self) -> Option<(PathBuf, RawDevice)> {
|
||||||
use std::os::unix::ffi::OsStrExt;
|
use std::os::unix::ffi::OsStrExt;
|
||||||
let readdir = self.readdir.as_mut()?;
|
let readdir = self.readdir.as_mut()?;
|
||||||
loop {
|
loop {
|
||||||
|
@ -666,7 +666,7 @@ impl Iterator for EnumerateDevices {
|
||||||
let fname = path.file_name().unwrap();
|
let fname = path.file_name().unwrap();
|
||||||
if fname.as_bytes().starts_with(b"event") {
|
if fname.as_bytes().starts_with(b"event") {
|
||||||
if let Ok(dev) = RawDevice::open(&path) {
|
if let Ok(dev) = RawDevice::open(&path) {
|
||||||
return Some(dev);
|
return Some((path, dev));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue