1
0
mirror of https://github.com/danog/libdvb.git synced 2024-11-30 04:19:00 +01:00

cleaning: remove thiserror

This commit is contained in:
Andrey Dyldin 2021-02-01 10:35:10 +02:00
parent 0aef88bedb
commit e4360f3e04
5 changed files with 14 additions and 43 deletions

View File

@ -14,4 +14,3 @@ edition = "2018"
[dependencies]
nix = "0.19"
anyhow = "1.0"
thiserror = "1.0"

View File

@ -26,7 +26,7 @@ fn check_ca(path: &Path) -> Result<()> {
fn main() -> Result<()> {
let mut args = std::env::args().skip(1);
if let Some(path) = args.next() {
let path = Path::new(path);
let path = Path::new(&path);
check_ca(&path)?;
} else {
eprintln!("path to ca device is not defined");

View File

@ -42,8 +42,7 @@ use {
#[derive(Debug)]
pub struct CaDevice {
file: File,
slot_id: u8
slot_id: u8,
}
@ -99,8 +98,7 @@ impl CaDevice {
}.context("CA: failed to get slot info")?;
if slot_info.flags == CA_CI_MODULE_NOT_FOUND {
println!("CA: module not found");
return Ok(());
return Err(anyhow!("CA: module not found"));
}
if slot_info.typ != CA_CI_LINK {

View File

@ -28,7 +28,6 @@ use {
Context,
Result,
},
thiserror::Error,
nix::{
ioctl_read,
@ -46,30 +45,6 @@ pub use {
};
/// The error type for frontend operations
#[derive(Debug, Error)]
pub enum FeError {
#[error("frontend is not char device")]
InvalidDeviceFormat,
#[error("frequency out of range")]
InvalidFrequency,
#[error("symbolrate out of range")]
InvalidSymbolrate,
#[error("unknown subsystem")]
InvalidSubsystem,
#[error("no auto inversion")]
NoAutoInversion,
#[error("no auto transmission mode")]
NoAutoTransmitMode,
#[error("no auto guard interval")]
NoAutoGuardInterval,
#[error("no auto hierarchy")]
NoAutoHierarchy,
#[error("multistream not supported")]
NoMultistream,
}
/// A reference to the frontend device and device information
#[derive(Debug)]
pub struct FeDevice {
@ -185,7 +160,7 @@ impl FeDevice {
ensure!(
metadata.file_type().is_char_device(),
FeError::InvalidDeviceFormat
"FE: path is not to char device"
);
Ok(())
@ -231,14 +206,14 @@ impl FeDevice {
let v = unsafe { p.u.data };
ensure!(
self.frequency_range.contains(&v),
FeError::InvalidFrequency
"FE: frequency out of range"
);
}
DTV_SYMBOL_RATE => {
let v = unsafe { p.u.data };
ensure!(
self.symbolrate_range.contains(&v),
FeError::InvalidSymbolrate
"FE: symbolrate out of range"
);
}
DTV_INVERSION => {
@ -246,7 +221,7 @@ impl FeDevice {
if v == INVERSION_AUTO {
ensure!(
self.caps & FE_CAN_INVERSION_AUTO != 0,
FeError::NoAutoInversion
"FE: auto inversion is not available"
);
}
}
@ -255,7 +230,7 @@ impl FeDevice {
if v == TRANSMISSION_MODE_AUTO {
ensure!(
self.caps & FE_CAN_TRANSMISSION_MODE_AUTO != 0,
FeError::NoAutoTransmitMode
"FE: no auto transmission mode"
);
}
}
@ -264,7 +239,7 @@ impl FeDevice {
if v == GUARD_INTERVAL_AUTO {
ensure!(
self.caps & FE_CAN_GUARD_INTERVAL_AUTO != 0,
FeError::NoAutoGuardInterval
"FE: no auto guard interval"
);
}
}
@ -273,14 +248,14 @@ impl FeDevice {
if v == HIERARCHY_AUTO {
ensure!(
self.caps & FE_CAN_HIERARCHY_AUTO != 0,
FeError::NoAutoHierarchy
"FE: no auto hierarchy"
);
}
}
DTV_STREAM_ID => {
ensure!(
self.caps & FE_CAN_MULTISTREAM != 0,
FeError::NoMultistream
"FE: no multistream"
);
}
_ => {}

View File

@ -81,7 +81,7 @@ impl fmt::Display for FeStatus {
return Ok(());
}
write!(f, " S:")?;
write!(f, " Signal:")?;
if let Some(s) = self.get_signal_level() {
// TODO: config for lo/hi
let lo: f64 = -85.0;
@ -96,10 +96,9 @@ impl fmt::Display for FeStatus {
return Ok(());
}
write!(f, " Q:")?;
write!(f, " Quality:")?;
if let Some(q) = self.get_signal_noise_ratio() {
let relative = q * 2.;
write!(f, "{:.02}dB ({:.0}%)", q, relative)?;
write!(f, "{:.02}dB", q)?;
} else {
write!(f, "-")?;
}