Skip to content

Commit

Permalink
fix: Parse profiles without LedMode without failing
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronErhardt committed Apr 8, 2024
1 parent 236f428 commit d2e938e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
5 changes: 4 additions & 1 deletion tailor_api/src/led.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#[derive(Debug, Copy, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash)]
#[derive(
Default, Debug, Copy, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash,
)]
#[non_exhaustive]
pub enum LedControllerMode {
#[default]
Rgb,
Monochrome,
}
Expand Down
1 change: 1 addition & 0 deletions tailor_api/src/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ pub struct LedProfile {
pub device_name: String,
pub function: String,
pub profile: String,
#[serde(default)]
pub mode: LedControllerMode,
}
2 changes: 1 addition & 1 deletion tailord/src/led/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl LedRuntime {
info: LedDeviceInfo {
device_name: data.controller.device_name.clone(),
function: data.controller.function.clone(),
mode: data.controller.mode().clone(),
mode: data.controller.mode(),
},
profile_sender,
color_sender,
Expand Down
5 changes: 0 additions & 5 deletions tailord/src/util.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use serde::{de::DeserializeOwned, Serialize};
use std::ffi::OsString;
use zbus::fdo;

pub fn normalize_json_path(base_path: &str, name: &str) -> fdo::Result<String> {
Expand All @@ -12,10 +11,6 @@ pub fn normalize_json_path(base_path: &str, name: &str) -> fdo::Result<String> {
Err(fdo::Error::InvalidArgs(format!(
"Can't use '.' in profile names: `{name}`"
)))
} else if let Err(err) = OsString::try_from(name) {
Err(fdo::Error::InvalidArgs(format!(
"Can't convert `{name}` to OS string: `{err}`"
)))
} else if base_path.is_empty() {
Ok(format!("{name}.json"))
} else {
Expand Down

0 comments on commit d2e938e

Please sign in to comment.