chore: cargo clippy -- -W clippy::pedantic

This commit is contained in:
Corentin LIAUD
2025-10-19 14:58:35 +02:00
parent 373a5265a0
commit e0b6bb0139
41 changed files with 175 additions and 176 deletions

View File

@@ -11,11 +11,11 @@ rust-version.workspace = true
version.workspace = true
[dependencies]
adb_client = { version = "^2.0.0" }
anyhow = { version = "1.0.94" }
clap = { version = "4.5.23", features = ["derive"] }
env_logger = { version = "0.11.5" }
log = { version = "0.4.26" }
adb_client = { version = "^2.1.17" }
anyhow = { version = "1.0.100" }
clap = { version = "4.5.49", features = ["derive"] }
env_logger = { version = "0.11.8" }
log = { version = "0.4.28" }
[target.'cfg(unix)'.dependencies]
termios = { version = "0.3.3" }

View File

@@ -13,7 +13,7 @@ pub struct ADBTermios {
}
impl ADBTermios {
pub fn new(fd: impl AsRawFd) -> Result<Self> {
pub fn new(fd: &impl AsRawFd) -> Result<Self> {
let mut new_termios = Termios::from_fd(fd.as_raw_fd())?;
let old_termios = new_termios; // Saves previous state
new_termios.c_lflag = 0;
@@ -36,7 +36,7 @@ impl Drop for ADBTermios {
fn drop(&mut self) {
// Custom drop implementation, restores previous termios structure.
if let Err(e) = tcsetattr(self.fd, TCSANOW, &self.old_termios) {
log::error!("Error while dropping ADBTermios: {e}")
log::error!("Error while dropping ADBTermios: {e}");
}
}
}

View File

@@ -53,12 +53,15 @@ pub fn handle_host_commands(server_command: ServerCommand<HostCommand>) -> Resul
let server_status = adb_server.server_status()?;
match server_status.mdns_backend {
MDNSBackend::Unknown => log::info!("unknown mdns backend..."),
MDNSBackend::Bonjour => match check {
true => log::info!("mdns daemon version [Bonjour]"),
false => log::info!("ERROR: mdns daemon unavailable"),
},
MDNSBackend::Bonjour => {
if check {
log::info!("mdns daemon version [Bonjour]");
} else {
log::info!("ERROR: mdns daemon unavailable");
}
}
MDNSBackend::OpenScreen => {
log::info!("mdns daemon version [Openscreen discovery 0.0.0]")
log::info!("mdns daemon version [Openscreen discovery 0.0.0]");
}
}
}

View File

@@ -14,7 +14,7 @@ pub fn handle_local_commands(
let features = device
.host_features()?
.iter()
.map(|v| v.to_string())
.map(ToString::to_string)
.reduce(|a, b| format!("{a},{b}"))
.ok_or(anyhow!("cannot list features"))?;
log::info!("Available host features: {features}");

View File

@@ -94,7 +94,7 @@ fn main() -> Result<()> {
"Found device {} with addresses {:?}",
device.fullname,
device.addresses
)
);
}
return Ok(service.shutdown()?);
@@ -108,7 +108,7 @@ fn main() -> Result<()> {
// Using a scope here would call drop() too early..
#[cfg(any(target_os = "linux", target_os = "macos"))]
{
let mut adb_termios = ADBTermios::new(std::io::stdin())?;
let mut adb_termios = ADBTermios::new(&std::io::stdin())?;
adb_termios.set_adb_termios()?;
device.shell(&mut std::io::stdin(), Box::new(std::io::stdout()))?;
}
@@ -118,7 +118,7 @@ fn main() -> Result<()> {
device.shell(&mut std::io::stdin(), Box::new(std::io::stdout()))?;
}
} else {
let commands: Vec<&str> = commands.iter().map(|v| v.as_str()).collect();
let commands: Vec<&str> = commands.iter().map(String::as_str).collect();
device.shell_command(&commands, &mut std::io::stdout())?;
}
}
@@ -136,7 +136,7 @@ fn main() -> Result<()> {
}
DeviceCommands::Reboot { reboot_type } => {
log::info!("Reboots device in mode {reboot_type:?}");
device.reboot(reboot_type.into())?
device.reboot(reboot_type.into())?;
}
DeviceCommands::Push { filename, path } => {
let mut input = File::open(Path::new(&filename))?;

View File

@@ -19,7 +19,7 @@ pub enum DeviceCommands {
/// The package whose activity is to be invoked
#[clap(short = 'p', long = "package")]
package: String,
/// The activity to be invoked itself, Usually it is MainActivity
/// The activity to be invoked itself, Usually it is `MainActivity`
#[clap(short = 'a', long = "activity")]
activity: String,
},

View File

@@ -5,10 +5,7 @@
pub unsafe fn setup_logger(debug: bool) {
// RUST_LOG variable has more priority then "--debug" flag
if std::env::var("RUST_LOG").is_err() {
let level = match debug {
true => "trace",
false => "info",
};
let level = if debug { "trace" } else { "info" };
unsafe { std::env::set_var("RUST_LOG", level) };
}