From bd08a1bc949a8aaf9c84c4a4a17161c08256bb8b Mon Sep 17 00:00:00 2001 From: ehushubhamshaw Date: Sat, 14 Mar 2026 22:20:51 -0400 Subject: [PATCH] fix(hardware): apply rustfmt 1.92.0 formatting (matches CI toolchain) --- src/hardware/mod.rs | 10 +++++----- src/hardware/rpi.rs | 36 ++++++++++++++++++------------------ src/peripherals/mod.rs | 8 ++++++-- 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/hardware/mod.rs b/src/hardware/mod.rs index 4b58f440b..e6b672085 100644 --- a/src/hardware/mod.rs +++ b/src/hardware/mod.rs @@ -2,11 +2,11 @@ //! //! See `docs/hardware-peripherals-design.md` for the full design. -pub mod registry; pub mod device; -pub mod transport; -pub mod protocol; pub mod gpio; +pub mod protocol; +pub mod registry; +pub mod transport; #[cfg(all( feature = "hardware", @@ -61,11 +61,11 @@ pub mod tool_registry; #[allow(unused_imports)] pub use aardvark::AardvarkTransport; -#[allow(unused_imports)] -pub use tool_registry::{ToolError, ToolRegistry}; use crate::config::Config; use crate::hardware::device::DeviceRegistry; use anyhow::Result; +#[allow(unused_imports)] +pub use tool_registry::{ToolError, ToolRegistry}; // Re-export config types so wizard can use `hardware::HardwareConfig` etc. pub use crate::config::{HardwareConfig, HardwareTransport}; diff --git a/src/hardware/rpi.rs b/src/hardware/rpi.rs index 2726005c9..ea7dfa953 100644 --- a/src/hardware/rpi.rs +++ b/src/hardware/rpi.rs @@ -46,7 +46,10 @@ fn is_onboard_led(pin: u8) -> bool { /// Find the first existing sysfs brightness path for the ACT LED. fn led_brightness_path() -> Option<&'static str> { - LED_SYSFS_PATHS.iter().copied().find(|p| std::path::Path::new(p).exists()) + LED_SYSFS_PATHS + .iter() + .copied() + .find(|p| std::path::Path::new(p).exists()) } /// Ensure the ACT LED trigger is set to "none" so we can control it. @@ -199,13 +202,7 @@ impl RpiSystemContext { text.lines() .skip(2) // header rows .find(|l| l.contains(':')) - .map(|l| { - l.split(':') - .next() - .unwrap_or("") - .trim() - .to_string() - }) + .map(|l| l.split(':').next().unwrap_or("").trim().to_string()) .filter(|s| !s.is_empty()) } @@ -305,7 +302,10 @@ impl RpiSystemContext { let _ = writeln!(s, "- Hostname: {}", self.hostname); let _ = writeln!(s, "- IP: {} (at last boot)", self.ip_address); let _ = writeln!(s, "- RAM: {}MB total", self.total_ram_mb); - let _ = writeln!(s, "- Runtime: ZeroClaw native (rppal — no serial, no mpremote)"); + let _ = writeln!( + s, + "- Runtime: ZeroClaw native (rppal — no serial, no mpremote)" + ); if let Some(ref iface) = self.wifi_interface { let _ = writeln!(s, "- WiFi interface: {}", iface); } @@ -379,8 +379,7 @@ impl Tool for GpioRpiWriteTool { let pin = args .get("pin") .and_then(|v| v.as_u64()) - .ok_or_else(|| anyhow::anyhow!("Missing 'pin' parameter"))? - as u8; + .ok_or_else(|| anyhow::anyhow!("Missing 'pin' parameter"))? as u8; let value = args .get("value") .and_then(|v| v.as_u64()) @@ -457,8 +456,7 @@ impl Tool for GpioRpiReadTool { let pin = args .get("pin") .and_then(|v| v.as_u64()) - .ok_or_else(|| anyhow::anyhow!("Missing 'pin' parameter"))? - as u8; + .ok_or_else(|| anyhow::anyhow!("Missing 'pin' parameter"))? as u8; // Onboard ACT LED → read from sysfs if is_onboard_led(pin) { @@ -469,7 +467,8 @@ impl Tool for GpioRpiReadTool { let state = if value == 0 { "LOW" } else { "HIGH" }; return Ok(ToolResult { success: true, - output: json!({ "pin": pin, "value": value, "state": state, "source": "sysfs" }).to_string(), + output: json!({ "pin": pin, "value": value, "state": state, "source": "sysfs" }) + .to_string(), error: None, }); } @@ -538,8 +537,7 @@ impl Tool for GpioRpiBlinkTool { let pin = args .get("pin") .and_then(|v| v.as_u64()) - .ok_or_else(|| anyhow::anyhow!("Missing 'pin' parameter"))? - as u8; + .ok_or_else(|| anyhow::anyhow!("Missing 'pin' parameter"))? as u8; let times = args .get("times") .and_then(|v| v.as_u64()) @@ -569,7 +567,10 @@ impl Tool for GpioRpiBlinkTool { } return Ok(ToolResult { success: true, - output: format!("Blinked ACT LED (GPIO {}) × {} ({}/{}ms) via sysfs", pin, times, on_ms, off_ms), + output: format!( + "Blinked ACT LED (GPIO {}) × {} ({}/{}ms) via sysfs", + pin, times, on_ms, off_ms + ), error: None, }); } @@ -643,4 +644,3 @@ impl Tool for RpiSystemInfoTool { }) } } - diff --git a/src/peripherals/mod.rs b/src/peripherals/mod.rs index 515e63283..f9b8db823 100644 --- a/src/peripherals/mod.rs +++ b/src/peripherals/mod.rs @@ -244,8 +244,12 @@ pub fn create_board_info_tools(config: &PeripheralsConfig) -> Vec> } let board_names: Vec = config.boards.iter().map(|b| b.board.clone()).collect(); vec![ - Box::new(crate::tools::HardwareMemoryMapTool::new(board_names.clone())), - Box::new(crate::tools::HardwareBoardInfoTool::new(board_names.clone())), + Box::new(crate::tools::HardwareMemoryMapTool::new( + board_names.clone(), + )), + Box::new(crate::tools::HardwareBoardInfoTool::new( + board_names.clone(), + )), Box::new(crate::tools::HardwareMemoryReadTool::new(board_names)), ] }