From 4e8dbf9f158cffedd45eb82d6e92766ada9872d9 Mon Sep 17 00:00:00 2001 From: Fabio Lenherr / DashieTM Date: Sat, 18 Nov 2023 19:36:38 +0100 Subject: [PATCH] fix: Change active profile to bool --- Cargo.toml | 2 +- src/audio/audio.rs | 21 ++++++++------------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5c38bb2..d7de18d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ReSet-Lib" -version = "0.2.9" +version = "0.3.0" edition = "2021" description = "Data structure library for ReSet" repository = "https://github.com/Xetibo/ReSet-Lib" diff --git a/src/audio/audio.rs b/src/audio/audio.rs index 12b3a0c..3ccab6d 100644 --- a/src/audio/audio.rs +++ b/src/audio/audio.rs @@ -350,7 +350,7 @@ pub struct Card { pub index: u32, pub name: String, pub profiles: Vec, - pub active_profile: String, + pub active_profile: bool, } impl Append for Card { @@ -367,7 +367,7 @@ impl Append for Card { impl<'a> Get<'a> for Card { fn get(i: &mut arg::Iter<'a>) -> Option { let (index, name, profiles, active_profile) = - <(u32, String, Vec, String)>::get(i)?; + <(u32, String, Vec, bool)>::get(i)?; Some(Self { index, name, @@ -380,12 +380,12 @@ impl<'a> Get<'a> for Card { impl Arg for Card { const ARG_TYPE: arg::ArgType = ArgType::Struct; fn signature() -> Signature<'static> { - unsafe { Signature::from_slice_unchecked("(usa(ssb)s)\0") } + unsafe { Signature::from_slice_unchecked("(usa(ssb)b)\0") } } } -impl From> for Card { - fn from(value: CardInfo<'_>) -> Self { +impl From<&CardInfo<'_>> for Card { + fn from(value: &CardInfo<'_>) -> Self { let name_opt = &value.name; let name: String; if name_opt.is_none() { @@ -398,16 +398,11 @@ impl From> for Card { for profile in value.profiles.iter() { profiles.push(CardProfile::from(profile)); } - let active_profile: String; + let active_profile: bool; if value.active_profile.is_some() { - active_profile = value - .active_profile - .unwrap() - .name - .unwrap_or_default() - .to_string(); + active_profile = true; } else { - active_profile = "".into(); + active_profile = false; } Self { index,