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

@@ -191,9 +191,7 @@ pub async fn apply_hid_config(
// Low-endpoint UDCs (e.g., musb) cannot handle consumer control endpoints reliably
if new_config.backend == HidBackend::Otg {
if let Some(udc) =
crate::otg::configfs::resolve_udc_name(new_config.otg_udc.as_deref())
{
if let Some(udc) = crate::otg::configfs::resolve_udc_name(new_config.otg_udc.as_deref()) {
if crate::otg::configfs::is_low_endpoint_udc(&udc) && new_hid_functions.consumer {
tracing::warn!(
"UDC {} has low endpoint resources, disabling consumer control",

View File

@@ -86,7 +86,7 @@ pub async fn start_extension(
// Start the extension
mgr.start(ext_id, &config.extensions)
.await
.map_err(|e| AppError::Internal(e))?;
.map_err(AppError::Internal)?;
// Return updated status
Ok(Json(ExtensionInfo {
@@ -108,7 +108,7 @@ pub async fn stop_extension(
let mgr = &state.extensions;
// Stop the extension
mgr.stop(ext_id).await.map_err(|e| AppError::Internal(e))?;
mgr.stop(ext_id).await.map_err(AppError::Internal)?;
// Return updated status
Ok(Json(ExtensionInfo {
@@ -263,14 +263,16 @@ pub async fn update_gostc_config(
if was_enabled && !is_enabled {
state.extensions.stop(ExtensionId::Gostc).await.ok();
} else if !was_enabled && is_enabled && has_key {
if state.extensions.check_available(ExtensionId::Gostc) {
state
.extensions
.start(ExtensionId::Gostc, &new_config.extensions)
.await
.ok();
}
} else if !was_enabled
&& is_enabled
&& has_key
&& state.extensions.check_available(ExtensionId::Gostc)
{
state
.extensions
.start(ExtensionId::Gostc, &new_config.extensions)
.await
.ok();
}
Ok(Json(new_config.extensions.gostc.clone()))
@@ -312,14 +314,16 @@ pub async fn update_easytier_config(
if was_enabled && !is_enabled {
state.extensions.stop(ExtensionId::Easytier).await.ok();
} else if !was_enabled && is_enabled && has_name {
if state.extensions.check_available(ExtensionId::Easytier) {
state
.extensions
.start(ExtensionId::Easytier, &new_config.extensions)
.await
.ok();
}
} else if !was_enabled
&& is_enabled
&& has_name
&& state.extensions.check_available(ExtensionId::Easytier)
{
state
.extensions
.start(ExtensionId::Easytier, &new_config.extensions)
.await
.ok();
}
Ok(Json(new_config.extensions.easytier.clone()))

View File

@@ -205,7 +205,7 @@ fn get_cpu_model() -> String {
.count();
Some(format!("{} {}C", std::env::consts::ARCH, cores))
})
.unwrap_or_else(|| format!("{}", std::env::consts::ARCH))
.unwrap_or_else(|| std::env::consts::ARCH.to_string())
}
/// CPU usage state for calculating usage between samples
@@ -686,8 +686,7 @@ pub async fn setup_init(
if matches!(new_config.hid.backend, crate::config::HidBackend::Otg) {
let mut hid_functions = new_config.hid.effective_otg_functions();
if let Some(udc) =
crate::otg::configfs::resolve_udc_name(new_config.hid.otg_udc.as_deref())
if let Some(udc) = crate::otg::configfs::resolve_udc_name(new_config.hid.otg_udc.as_deref())
{
if crate::otg::configfs::is_low_endpoint_udc(&udc) && hid_functions.consumer {
tracing::warn!(
@@ -1842,12 +1841,12 @@ pub async fn mjpeg_stream(
break;
}
// Send last frame again to keep connection alive
if let Some(frame) = handler_clone.current_frame() {
if frame.is_valid_jpeg() {
if tx.send(create_mjpeg_part(frame.data())).await.is_err() {
break;
}
}
let Some(frame) = handler_clone.current_frame() else {
continue;
};
if frame.is_valid_jpeg() && tx.send(create_mjpeg_part(frame.data())).await.is_err() {
break;
}
}
}
@@ -1866,7 +1865,7 @@ pub async fn mjpeg_stream(
yield Ok::<bytes::Bytes, std::io::Error>(data);
// Record FPS after yield - data has been handed to Axum/hyper
// This is closer to actual TCP send than recording at tx.send()
handler_for_stream.record_frame_sent(&guard_for_stream.id());
handler_for_stream.record_frame_sent(guard_for_stream.id());
}
};
@@ -2516,7 +2515,7 @@ pub async fn msd_drive_download(
let (file_size, mut rx) = drive.read_file_stream(&file_path).await?;
// Extract filename for Content-Disposition
let filename = file_path.split('/').last().unwrap_or("download");
let filename = file_path.split('/').next_back().unwrap_or("download");
// Create a stream from the channel receiver
let body_stream = async_stream::stream! {