|
1 | 1 | use crate::video::uvc::XuControl; |
2 | 2 |
|
3 | | -use std::io::{Error, ErrorKind, Result}; |
| 3 | +use std::io::{Error, Result}; |
4 | 4 | use std::os::fd::AsFd; |
5 | 5 | use std::path::{Path, PathBuf}; |
6 | 6 |
|
@@ -80,23 +80,19 @@ impl Device { |
80 | 80 | } |
81 | 81 |
|
82 | 82 | /// Tries to get all the control descriptions of the device. |
83 | | - /// |
84 | | - /// An empty list will be returned if the device has no controls. |
85 | | - pub fn controls(&self) -> Result<Vec<XuControl>> { |
| 83 | + /// An empty list will be returned if the device no controls can be found |
| 84 | + pub fn controls(&self) -> Vec<XuControl> { |
86 | 85 | let mut controls = Vec::new(); |
87 | 86 | // Search for all possible combination of unit and selector |
88 | 87 | for unit in 0..255 { |
89 | 88 | for selector in 0..255 { |
90 | 89 | match self.find_control(unit, selector) { |
91 | 90 | Ok(control) => controls.push(control), |
92 | | - Err(err) => match err.kind() { |
93 | | - ErrorKind::NotFound | ErrorKind::PermissionDenied => {} |
94 | | - _ => return Err(err), |
95 | | - }, |
| 91 | + Err(_) => {} // Ignore all errors |
96 | 92 | } |
97 | 93 | } |
98 | 94 | } |
99 | | - Ok(controls) |
| 95 | + controls |
100 | 96 | } |
101 | 97 |
|
102 | 98 | /// Tries to apply the control to the device. |
@@ -204,13 +200,8 @@ impl std::fmt::Display for Device { |
204 | 200 | .as_ref() |
205 | 201 | .map_or("unknown".into(), |p| p.display().to_string()) |
206 | 202 | )?; |
207 | | - match self.controls() { |
208 | | - Err(err) => writeln!(f, " Failed to get the controls: {err:?}")?, |
209 | | - Ok(controls) => { |
210 | | - for control in controls { |
211 | | - writeln!(f, " {}", control)?; |
212 | | - } |
213 | | - } |
| 203 | + for control in self.controls() { |
| 204 | + writeln!(f, " {}", control)?; |
214 | 205 | } |
215 | 206 | Ok(()) |
216 | 207 | } |
|
0 commit comments