fix: 补齐 ATX 控制器缺失接口并完成全项目 clippy -D warnings 修复

This commit is contained in:
mofeng-git
2026-02-10 21:37:33 +08:00
parent 72eb2c450d
commit 394baca938
64 changed files with 474 additions and 760 deletions

View File

@@ -52,10 +52,7 @@ impl MsdController {
/// # Parameters
/// * `otg_service` - OTG service for gadget management
/// * `msd_dir` - Base directory for MSD storage
pub fn new(
otg_service: Arc<OtgService>,
msd_dir: impl Into<PathBuf>,
) -> Self {
pub fn new(otg_service: Arc<OtgService>, msd_dir: impl Into<PathBuf>) -> Self {
let msd_dir = msd_dir.into();
let images_path = msd_dir.join("images");
let ventoy_dir = msd_dir.join("ventoy");

View File

@@ -88,7 +88,7 @@ impl ImageManager {
.and_then(|t| t.duration_since(std::time::UNIX_EPOCH).ok())
.map(|d| {
chrono::DateTime::from_timestamp(d.as_secs() as i64, 0)
.unwrap_or_else(|| Utc::now().into())
.unwrap_or_else(Utc::now)
})
.unwrap_or_else(Utc::now);
@@ -400,7 +400,7 @@ impl ImageManager {
.headers()
.get(reqwest::header::CONTENT_DISPOSITION)
.and_then(|v| v.to_str().ok())
.and_then(|s| extract_filename_from_content_disposition(s));
.and_then(extract_filename_from_content_disposition);
if let Some(name) = from_header {
sanitize_filename(&name)

View File

@@ -16,8 +16,10 @@ use crate::utils::LogThrottler;
/// MSD health status
#[derive(Debug, Clone, PartialEq)]
#[derive(Default)]
pub enum MsdHealthStatus {
/// Device is healthy and operational
#[default]
Healthy,
/// Device has an error
Error {
@@ -28,11 +30,6 @@ pub enum MsdHealthStatus {
},
}
impl Default for MsdHealthStatus {
fn default() -> Self {
Self::Healthy
}
}
/// MSD health monitor configuration
#[derive(Debug, Clone)]

View File

@@ -7,8 +7,10 @@ use std::path::PathBuf;
/// MSD operating mode
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[derive(Default)]
pub enum MsdMode {
/// No storage connected
#[default]
None,
/// Image file mounted (ISO/IMG)
Image,
@@ -16,11 +18,6 @@ pub enum MsdMode {
Drive,
}
impl Default for MsdMode {
fn default() -> Self {
Self::None
}
}
/// Image file metadata
#[derive(Debug, Clone, Serialize, Deserialize)]

View File

@@ -328,8 +328,7 @@ impl VentoyDrive {
let image = match VentoyImage::open(&path) {
Ok(img) => img,
Err(e) => {
let _ = rt.block_on(tx.send(Err(std::io::Error::new(
std::io::ErrorKind::Other,
let _ = rt.block_on(tx.send(Err(std::io::Error::other(
e.to_string(),
))));
return;
@@ -341,8 +340,7 @@ impl VentoyDrive {
// Stream the file through the writer
if let Err(e) = image.read_file_to_writer(&file_path_owned, &mut chunk_writer) {
let _ = rt.block_on(tx.send(Err(std::io::Error::new(
std::io::ErrorKind::Other,
let _ = rt.block_on(tx.send(Err(std::io::Error::other(
e.to_string(),
))));
}
@@ -543,12 +541,11 @@ mod tests {
/// Decompress xz file using system command
fn decompress_xz(src: &std::path::Path, dst: &std::path::Path) -> std::io::Result<()> {
let output = Command::new("xz")
.args(&["-d", "-k", "-c", src.to_str().unwrap()])
.args(["-d", "-k", "-c", src.to_str().unwrap()])
.output()?;
if !output.status.success() {
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
return Err(std::io::Error::other(
format!(
"xz decompress failed: {}",
String::from_utf8_lossy(&output.stderr)