mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-12 09:22:26 -04:00
manager: Make match indent towers more idiomatic
This commit is contained in:
parent
2e55bc2330
commit
dce3ad8437
1 changed files with 69 additions and 93 deletions
162
src/manager.rs
162
src/manager.rs
|
@ -356,27 +356,21 @@ impl SMManager {
|
||||||
// write value
|
// write value
|
||||||
let data = format!("s 0 {clocks}\n");
|
let data = format!("s 0 {clocks}\n");
|
||||||
let result = myfile.write(data.as_bytes()).await;
|
let result = myfile.write(data.as_bytes()).await;
|
||||||
|
if let Err(message) = result {
|
||||||
|
println!("Error writing to sysfs file {message}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let data = format!("s 1 {clocks}\n");
|
||||||
|
let result = myfile.write(data.as_bytes()).await;
|
||||||
|
if let Err(message) = result {
|
||||||
|
println!("Error writing to sysfs file {message}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let result = myfile.write("c\n".as_bytes()).await;
|
||||||
match result {
|
match result {
|
||||||
Ok(_worked) => {
|
Ok(_worked) => true,
|
||||||
let data = format!("s 1 {clocks}\n");
|
|
||||||
let result = myfile.write(data.as_bytes()).await;
|
|
||||||
match result {
|
|
||||||
Ok(_worked) => {
|
|
||||||
let result = myfile.write("c\n".as_bytes()).await;
|
|
||||||
match result {
|
|
||||||
Ok(_worked) => true,
|
|
||||||
Err(message) => {
|
|
||||||
println!("Error writing to sysfs file {message}");
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(message) => {
|
|
||||||
println!("Error writing to sysfs file {message}");
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(message) => {
|
Err(message) => {
|
||||||
println!("Error writing to sysfs file {message}");
|
println!("Error writing to sysfs file {message}");
|
||||||
false
|
false
|
||||||
|
@ -460,48 +454,37 @@ impl SMManager {
|
||||||
Ok(WifiDebugMode::Off) => {
|
Ok(WifiDebugMode::Off) => {
|
||||||
// If mode is 0 disable wifi debug mode
|
// If mode is 0 disable wifi debug mode
|
||||||
// Stop any existing trace and flush to disk.
|
// Stop any existing trace and flush to disk.
|
||||||
match stop_tracing(self.should_trace).await {
|
let result = match stop_tracing(self.should_trace).await {
|
||||||
Ok(result) => {
|
Ok(result) => result,
|
||||||
if result {
|
|
||||||
// Stop_tracing was successful
|
|
||||||
match setup_iwd_config(false).await {
|
|
||||||
Ok(_) => {
|
|
||||||
// setup_iwd_config false worked
|
|
||||||
match restart_iwd().await {
|
|
||||||
Ok(value) => {
|
|
||||||
if value {
|
|
||||||
// restart iwd worked
|
|
||||||
self.wifi_debug_mode = WifiDebugMode::Off;
|
|
||||||
} else {
|
|
||||||
// restart_iwd failed
|
|
||||||
println!(
|
|
||||||
"restart_iwd failed somehow, check log above"
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(message) => {
|
|
||||||
println!("restart_iwd got an error {message}");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(message) => {
|
|
||||||
println!(
|
|
||||||
"setup_iwd_config false got an error somehow {message}"
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
println!("stop_tracing command failed somehow, bailing");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(message) => {
|
Err(message) => {
|
||||||
println!("stop_tracing command had an error {message}");
|
println!("stop_tracing command had an error {message}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
if !result {
|
||||||
|
println!("stop_tracing command failed somehow, bailing");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Stop_tracing was successful
|
||||||
|
if let Err(message) = setup_iwd_config(false).await {
|
||||||
|
println!("setup_iwd_config false got an error somehow {message}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// setup_iwd_config false worked
|
||||||
|
let value = match restart_iwd().await {
|
||||||
|
Ok(value) => value,
|
||||||
|
Err(message) => {
|
||||||
|
println!("restart_iwd got an error {message}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if value {
|
||||||
|
// restart iwd worked
|
||||||
|
self.wifi_debug_mode = WifiDebugMode::Off;
|
||||||
|
} else {
|
||||||
|
// restart_iwd failed
|
||||||
|
println!("restart_iwd failed somehow, check log above");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(WifiDebugMode::On) => {
|
Ok(WifiDebugMode::On) => {
|
||||||
|
@ -510,44 +493,37 @@ impl SMManager {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
match setup_iwd_config(true).await {
|
if let Err(message) = setup_iwd_config(true).await {
|
||||||
Ok(_) => {
|
println!("setup_iwd_config true got an error somehow {message}");
|
||||||
// setup_iwd_config worked
|
return false;
|
||||||
match restart_iwd().await {
|
}
|
||||||
Ok(value) => {
|
// setup_iwd_config worked
|
||||||
if value {
|
let value = match restart_iwd().await {
|
||||||
// restart_iwd worked
|
Ok(value) => value,
|
||||||
match start_tracing(buffer_size, self.should_trace).await {
|
|
||||||
Ok(value) => {
|
|
||||||
if value {
|
|
||||||
// start_tracing worked
|
|
||||||
self.wifi_debug_mode = WifiDebugMode::On;
|
|
||||||
} else {
|
|
||||||
// start_tracing failed
|
|
||||||
println!("start_tracing failed somehow");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(message) => {
|
|
||||||
println!("start_tracing got an error {message}");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
println!("restart_iwd failed somehow");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(message) => {
|
|
||||||
println!("restart_iwd got an error {message}");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(message) => {
|
Err(message) => {
|
||||||
println!("setup_iwd_config true got an error somehow {message}");
|
println!("restart_iwd got an error {message}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
if !value {
|
||||||
|
println!("restart_iwd failed somehow");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// restart_iwd worked
|
||||||
|
let value = match start_tracing(buffer_size, self.should_trace).await {
|
||||||
|
Ok(value) => value,
|
||||||
|
Err(message) => {
|
||||||
|
println!("start_tracing got an error {message}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if value {
|
||||||
|
// start_tracing worked
|
||||||
|
self.wifi_debug_mode = WifiDebugMode::On;
|
||||||
|
} else {
|
||||||
|
// start_tracing failed
|
||||||
|
println!("start_tracing failed somehow");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue