Skip to content
This repository was archived by the owner on Nov 21, 2025. It is now read-only.

Commit 0965af5

Browse files
committed
style: Fix rustfmt formatting violations
Auto-format code to pass CI lint checks: - midimon-daemon: menu_bar.rs, midimon_menubar.rs - midimon-gui/src-tauri: 8 files formatted All changes are automatic formatting from cargo fmt --all No functional changes
1 parent dcf2579 commit 0965af5

10 files changed

Lines changed: 330 additions & 238 deletions

File tree

midimon-daemon/src/bin/midimon_menubar.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77
//! Communicates with the midimon daemon via IPC.
88
99
use midimon_daemon::daemon::{
10-
IconState, MenuAction, MenuBar, MenuBarError,
11-
IpcClient, IpcCommand, IpcRequest, ResponseStatus,
10+
IconState, IpcClient, IpcCommand, IpcRequest, MenuAction, MenuBar, MenuBarError, ResponseStatus,
1211
};
13-
use uuid::Uuid;
1412
use std::time::Duration;
1513
use tokio::time;
14+
use uuid::Uuid;
1615

1716
#[tokio::main]
1817
async fn main() {
@@ -164,11 +163,13 @@ fn extract_status(response: &str) -> Option<String> {
164163
if let Ok(value) = serde_json::from_str::<serde_json::Value>(response) {
165164
// Try to extract daemon info
166165
if let Some(daemon) = value.get("daemon") {
167-
let state = daemon.get("lifecycle_state")
166+
let state = daemon
167+
.get("lifecycle_state")
168168
.and_then(|v| v.as_str())
169169
.unwrap_or("Unknown");
170170

171-
let uptime = daemon.get("uptime_seconds")
171+
let uptime = daemon
172+
.get("uptime_seconds")
172173
.and_then(|v| v.as_f64())
173174
.map(format_duration)
174175
.unwrap_or_else(|| "Unknown".to_string());

midimon-daemon/src/daemon/menu_bar.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@
1313
//! - Linux: Uses libayatana-appindicator
1414
//! - Windows: System tray integration
1515
16+
use crossbeam_channel::Receiver;
1617
use tray_icon::{
17-
Icon, TrayIcon, TrayIconBuilder,
18-
menu::{Menu, MenuItem, PredefinedMenuItem, Submenu, MenuEvent},
19-
TrayIconEvent,
18+
Icon, TrayIcon, TrayIconBuilder, TrayIconEvent,
19+
menu::{Menu, MenuEvent, MenuItem, PredefinedMenuItem, Submenu},
2020
};
21-
use crossbeam_channel::Receiver;
2221

2322
#[cfg(target_os = "macos")]
2423
use cocoa::base::{id, nil};
@@ -202,24 +201,21 @@ impl MenuBar {
202201
fn create_running_icon() -> Result<Icon, MenuBarError> {
203202
// Create a simple 16x16 green circle icon
204203
let rgba = Self::create_circle_icon([0, 200, 0, 255]); // Green
205-
Icon::from_rgba(rgba, 16, 16)
206-
.map_err(|e| MenuBarError::IconCreationFailed(e.to_string()))
204+
Icon::from_rgba(rgba, 16, 16).map_err(|e| MenuBarError::IconCreationFailed(e.to_string()))
207205
}
208206

209207
/// Create the stopped state icon (gray)
210208
fn create_stopped_icon() -> Result<Icon, MenuBarError> {
211209
// Create a simple 16x16 gray circle icon
212210
let rgba = Self::create_circle_icon([128, 128, 128, 255]); // Gray
213-
Icon::from_rgba(rgba, 16, 16)
214-
.map_err(|e| MenuBarError::IconCreationFailed(e.to_string()))
211+
Icon::from_rgba(rgba, 16, 16).map_err(|e| MenuBarError::IconCreationFailed(e.to_string()))
215212
}
216213

217214
/// Create the error state icon (red)
218215
fn create_error_icon() -> Result<Icon, MenuBarError> {
219216
// Create a simple 16x16 red circle icon
220217
let rgba = Self::create_circle_icon([200, 0, 0, 255]); // Red
221-
Icon::from_rgba(rgba, 16, 16)
222-
.map_err(|e| MenuBarError::IconCreationFailed(e.to_string()))
218+
Icon::from_rgba(rgba, 16, 16).map_err(|e| MenuBarError::IconCreationFailed(e.to_string()))
223219
}
224220

225221
/// Create a simple circular icon with the given color
@@ -239,7 +235,7 @@ impl MenuBar {
239235
let idx = ((y * size + x) * 4) as usize;
240236
if distance <= radius {
241237
// Inside circle - use the specified color
242-
rgba[idx] = color[0]; // R
238+
rgba[idx] = color[0]; // R
243239
rgba[idx + 1] = color[1]; // G
244240
rgba[idx + 2] = color[2]; // B
245241
rgba[idx + 3] = color[3]; // A

midimon-gui/src-tauri/src/app_detection.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
99
use serde::{Deserialize, Serialize};
1010
use std::sync::Arc;
11-
use tokio::sync::RwLock;
1211
use std::time::Duration;
12+
use tokio::sync::RwLock;
1313

1414
#[cfg(target_os = "macos")]
1515
use cocoa::appkit::NSRunningApplication;
1616
#[cfg(target_os = "macos")]
1717
use cocoa::base::{id, nil};
1818
#[cfg(target_os = "macos")]
19-
use cocoa::foundation::{NSString, NSAutoreleasePool};
19+
use cocoa::foundation::{NSAutoreleasePool, NSString};
2020
#[cfg(target_os = "macos")]
2121
use objc::{class, msg_send, sel, sel_impl};
2222

@@ -263,11 +263,13 @@ mod tests {
263263
let detector_ref = Arc::new(detector);
264264

265265
let detector_clone = Arc::clone(&detector_ref);
266-
detector_clone.start_detection(|app| {
267-
if let Some(app_info) = app {
268-
println!("App changed to: {}", app_info.name);
269-
}
270-
}).await;
266+
detector_clone
267+
.start_detection(|app| {
268+
if let Some(app_info) = app {
269+
println!("App changed to: {}", app_info.name);
270+
}
271+
})
272+
.await;
271273

272274
assert!(detector_ref.is_active().await);
273275

midimon-gui/src-tauri/src/commands.rs

Lines changed: 51 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,17 @@
33

44
//! Tauri commands for interacting with the MIDIMon daemon
55
6+
use crate::config_helpers::{config_to_json, generate_mapping_toml, suggestion_to_config};
7+
use crate::device_templates::{DeviceTemplate, DeviceTemplateRegistry};
8+
use crate::midi_learn::{LearnSessionState, MidiLearnResult, MidiLearnSession, TriggerSuggestion};
9+
use crate::state::AppState;
610
use serde::{Deserialize, Serialize};
711
use serde_json::json;
812
use tauri::State;
913
use uuid::Uuid;
10-
use crate::state::AppState;
11-
use crate::midi_learn::{MidiLearnSession, MidiLearnResult, LearnSessionState, TriggerSuggestion};
12-
use crate::config_helpers::{suggestion_to_config, generate_mapping_toml, config_to_json};
13-
use crate::device_templates::{DeviceTemplate, DeviceTemplateRegistry};
1414

1515
// Import daemon types (we'll re-export these from daemon crate)
16-
use midimon_daemon::daemon::{
17-
IpcClient, IpcCommand, IpcRequest, ResponseStatus,
18-
};
16+
use midimon_daemon::daemon::{IpcClient, IpcCommand, IpcRequest, ResponseStatus};
1917

2018
/// Daemon status information for UI
2119
#[derive(Debug, Serialize, Deserialize)]
@@ -71,24 +69,30 @@ pub async fn get_daemon_status(state: State<'_, AppState>) -> Result<DaemonStatu
7169

7270
// Parse daemon info from response
7371
if let Some(data) = response.data {
74-
let lifecycle_state = data.get("daemon")
72+
let lifecycle_state = data
73+
.get("daemon")
7574
.and_then(|d| d.get("lifecycle_state"))
7675
.and_then(|s| s.as_str())
7776
.map(String::from);
7877

79-
let uptime_secs = data.get("daemon")
78+
let uptime_secs = data
79+
.get("daemon")
8080
.and_then(|d| d.get("uptime_seconds"))
8181
.and_then(|u| u.as_u64());
8282

83-
let events_processed = data.get("statistics")
83+
let events_processed = data
84+
.get("statistics")
8485
.and_then(|s| s.get("events_processed"))
8586
.and_then(|e| e.as_u64());
8687

8788
let device = data.get("device").and_then(|d| {
8889
Some(DeviceInfo {
8990
connected: d.get("connected")?.as_bool()?,
9091
name: d.get("name").and_then(|n| n.as_str()).map(String::from),
91-
port: d.get("port").and_then(|p| p.as_u64()).map(|p| p as usize),
92+
port: d
93+
.get("port")
94+
.and_then(|p| p.as_u64())
95+
.map(|p| p as usize),
9296
})
9397
});
9498

@@ -113,7 +117,8 @@ pub async fn get_daemon_status(state: State<'_, AppState>) -> Result<DaemonStatu
113117
})
114118
}
115119
} else {
116-
let error_msg = response.error
120+
let error_msg = response
121+
.error
117122
.map(|e| e.message)
118123
.unwrap_or_else(|| "Unknown error".to_string());
119124

@@ -237,22 +242,26 @@ pub async fn validate_config(_state: State<'_, AppState>) -> Result<ConfigValida
237242
ResponseStatus::Success => {
238243
// Parse validation result from response data
239244
if let Some(data) = response.data {
240-
let valid = data.get("valid")
241-
.and_then(|v| v.as_bool())
242-
.unwrap_or(true);
245+
let valid = data.get("valid").and_then(|v| v.as_bool()).unwrap_or(true);
243246

244-
let errors = data.get("errors")
247+
let errors = data
248+
.get("errors")
245249
.and_then(|e| e.as_array())
246-
.map(|arr| arr.iter()
247-
.filter_map(|v| v.as_str().map(String::from))
248-
.collect())
250+
.map(|arr| {
251+
arr.iter()
252+
.filter_map(|v| v.as_str().map(String::from))
253+
.collect()
254+
})
249255
.unwrap_or_default();
250256

251-
let warnings = data.get("warnings")
257+
let warnings = data
258+
.get("warnings")
252259
.and_then(|w| w.as_array())
253-
.map(|arr| arr.iter()
254-
.filter_map(|v| v.as_str().map(String::from))
255-
.collect())
260+
.map(|arr| {
261+
arr.iter()
262+
.filter_map(|v| v.as_str().map(String::from))
263+
.collect()
264+
})
256265
.unwrap_or_default();
257266

258267
Ok(ConfigValidation {
@@ -373,8 +382,8 @@ pub async fn save_config(
373382
#[tauri::command]
374383
pub async fn get_config_path() -> Result<String, String> {
375384
// Use the same logic as daemon to find config path
376-
let config_dir = dirs::config_dir()
377-
.ok_or_else(|| "Failed to determine config directory".to_string())?;
385+
let config_dir =
386+
dirs::config_dir().ok_or_else(|| "Failed to determine config directory".to_string())?;
378387

379388
let config_path = config_dir.join("midimon").join("config.toml");
380389

@@ -398,7 +407,9 @@ pub async fn start_midi_learn(
398407

399408
/// Get the status of the current MIDI Learn session
400409
#[tauri::command]
401-
pub async fn get_midi_learn_status(state: State<'_, AppState>) -> Result<LearnSessionState, String> {
410+
pub async fn get_midi_learn_status(
411+
state: State<'_, AppState>,
412+
) -> Result<LearnSessionState, String> {
402413
let session = state.get_learn_session().await;
403414
match session {
404415
Some(s) => Ok(s.get_state().await),
@@ -428,7 +439,9 @@ pub async fn cancel_midi_learn(state: State<'_, AppState>) -> Result<(), String>
428439

429440
/// Get the result of the MIDI Learn session
430441
#[tauri::command]
431-
pub async fn get_midi_learn_result(state: State<'_, AppState>) -> Result<Option<MidiLearnResult>, String> {
442+
pub async fn get_midi_learn_result(
443+
state: State<'_, AppState>,
444+
) -> Result<Option<MidiLearnResult>, String> {
432445
let session = state.get_learn_session().await;
433446
match session {
434447
Some(s) => {
@@ -437,7 +450,7 @@ pub async fn get_midi_learn_result(state: State<'_, AppState>) -> Result<Option<
437450
s.set_timed_out().await;
438451
}
439452
Ok(s.get_result().await)
440-
},
453+
}
441454
None => Ok(None),
442455
}
443456
}
@@ -454,14 +467,18 @@ pub fn generate_trigger_config_toml(
454467

455468
/// Convert trigger suggestion to JSON config
456469
#[tauri::command]
457-
pub fn trigger_suggestion_to_json(suggestion: TriggerSuggestion) -> Result<serde_json::Value, String> {
470+
pub fn trigger_suggestion_to_json(
471+
suggestion: TriggerSuggestion,
472+
) -> Result<serde_json::Value, String> {
458473
let config = suggestion_to_config(&suggestion);
459474
Ok(config_to_json(&config))
460475
}
461476

462477
/// Get the current frontmost application
463478
#[tauri::command]
464-
pub async fn get_frontmost_app(state: State<'_, AppState>) -> Result<Option<crate::app_detection::AppInfo>, String> {
479+
pub async fn get_frontmost_app(
480+
state: State<'_, AppState>,
481+
) -> Result<Option<crate::app_detection::AppInfo>, String> {
465482
Ok(state.get_current_app().await)
466483
}
467484

@@ -481,7 +498,9 @@ pub async fn stop_app_monitoring(state: State<'_, AppState>) -> Result<(), Strin
481498

482499
/// List all registered profiles
483500
#[tauri::command]
484-
pub async fn list_profiles(state: State<'_, AppState>) -> Result<Vec<crate::profile_manager::AppProfile>, String> {
501+
pub async fn list_profiles(
502+
state: State<'_, AppState>,
503+
) -> Result<Vec<crate::profile_manager::AppProfile>, String> {
485504
let manager = state.get_profile_manager().await;
486505
Ok(manager.list_profiles().await)
487506
}
@@ -625,9 +644,7 @@ pub fn list_templates_by_category(category: String) -> Result<Vec<DeviceTemplate
625644

626645
/// Create a config from a template
627646
#[tauri::command]
628-
pub fn create_config_from_template(
629-
template_id: String,
630-
) -> Result<String, String> {
647+
pub fn create_config_from_template(template_id: String) -> Result<String, String> {
631648
let registry = DeviceTemplateRegistry::new();
632649
registry.create_config_from_template(&template_id)
633650
}

0 commit comments

Comments
 (0)