diff --git a/wfassoc/src/highlevel.rs b/wfassoc/src/highlevel.rs index 5dea570..66312bc 100644 --- a/wfassoc/src/highlevel.rs +++ b/wfassoc/src/highlevel.rs @@ -284,13 +284,13 @@ impl Program { /// Internal used enum presenting a Program string resource. #[derive(Debug)] struct ProgramStr { - inner: lowlevel::LosseStrRefStr, + inner: lowlevel::StrResVariant, } /// Internal used enum presenting a Program icon resource. #[derive(Debug)] struct ProgramIcon { - inner: lowlevel::LosseIconRefStr, + inner: lowlevel::IconResVariant, } /// Internal used enum presenting a Program behavior (command line setups). diff --git a/wfassoc/src/lowlevel.rs b/wfassoc/src/lowlevel.rs index 6cfcb3f..7efabc9 100644 --- a/wfassoc/src/lowlevel.rs +++ b/wfassoc/src/lowlevel.rs @@ -85,7 +85,7 @@ impl TryFrom for Scope { // endregion -// region: Losse Structs +// region: Losse and Variant Structs // region: Losse ProgId @@ -129,7 +129,7 @@ impl From for LosseProgId { // endregion -// region: Losse Icon Reference String +// region: Icon Resource Variant /// The enum representing a losse Icon Reference String. /// @@ -137,35 +137,35 @@ impl From for LosseProgId { /// or a plain string pointing to a icon file as the icon setting value. /// This enum is designed for handling this scenario. #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub enum LosseIconRefStr { +pub enum IconResVariant { Plain(String), - Strict(concept::IconRefStr), + RefStr(concept::IconRefStr), } -impl LosseIconRefStr { +impl IconResVariant { pub fn extract(&self, kind: concept::IconSizeKind) -> Result { let rc = match self { - LosseIconRefStr::Plain(v) => concept::IconRc::with_ico_file(v.as_str(), kind)?, - LosseIconRefStr::Strict(v) => concept::IconRc::new(v.get_path(), v.get_index(), kind)?, + IconResVariant::Plain(v) => concept::IconRc::with_ico_file(v.as_str(), kind)?, + IconResVariant::RefStr(v) => concept::IconRc::new(v.get_path(), v.get_index(), kind)?, }; Ok(rc) } } -impl Display for LosseIconRefStr { +impl Display for IconResVariant { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - LosseIconRefStr::Plain(v) => v.fmt(f), - LosseIconRefStr::Strict(v) => v.fmt(f), + IconResVariant::Plain(v) => v.fmt(f), + IconResVariant::RefStr(v) => v.fmt(f), } } } -impl From<&str> for LosseIconRefStr { +impl From<&str> for IconResVariant { fn from(s: &str) -> Self { // match it for standard IconRefStr first if let Ok(v) = concept::IconRefStr::from_str(s) { - Self::Strict(v) + Self::RefStr(v) } else { // fallback with other Self::Plain(s.to_string()) @@ -173,15 +173,15 @@ impl From<&str> for LosseIconRefStr { } } -impl From for LosseIconRefStr { +impl From for IconResVariant { fn from(value: concept::IconRefStr) -> Self { - Self::Strict(value) + Self::RefStr(value) } } // endregion -// region: Losse String Reference String +// region: String Resource Variant /// The enum representing a losse String Reference String. /// @@ -189,18 +189,18 @@ impl From for LosseIconRefStr { /// or a plain string as the string setting value. /// This enum is designed for handling this scenario. #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub enum LosseStrRefStr { +pub enum StrResVariant { Plain(String), - Strict(concept::StrRefStr), + RefStr(concept::StrRefStr), } -impl LosseStrRefStr { +impl StrResVariant { pub fn extract(&self) -> Result { let rv = match self { // For plain string, we just simply clone it. - LosseStrRefStr::Plain(v) => v.clone(), + StrResVariant::Plain(v) => v.clone(), // For string reference string, we try to resolve it. - LosseStrRefStr::Strict(v) => { + StrResVariant::RefStr(v) => { let rc = concept::StrRc::new(v.get_path(), v.get_index())?; rc.into_string() }, @@ -209,20 +209,20 @@ impl LosseStrRefStr { } } -impl Display for LosseStrRefStr { +impl Display for StrResVariant { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - LosseStrRefStr::Plain(v) => v.fmt(f), - LosseStrRefStr::Strict(v) => v.fmt(f), + StrResVariant::Plain(v) => v.fmt(f), + StrResVariant::RefStr(v) => v.fmt(f), } } } -impl From<&str> for LosseStrRefStr { +impl From<&str> for StrResVariant { fn from(s: &str) -> Self { // match it for standard StrRefStr first if let Ok(v) = concept::StrRefStr::from_str(s) { - Self::Strict(v) + Self::RefStr(v) } else { // fallback with other Self::Plain(s.to_string()) @@ -230,9 +230,9 @@ impl From<&str> for LosseStrRefStr { } } -impl From for LosseStrRefStr { +impl From for StrResVariant { fn from(value: concept::StrRefStr) -> Self { - Self::Strict(value) + Self::RefStr(value) } } @@ -582,21 +582,21 @@ impl ApplicationsKey { const NAMEOF_DEFAULT_ICON: &str = "DefaultIcon"; - pub fn get_default_icon(&self, view: View) -> Result, Error> { + pub fn get_default_icon(&self, view: View) -> Result, Error> { todo!() } - pub fn set_default_icon(&self, scope: Scope, icon: Option<&LosseIconRefStr>) -> Result<(), Error> { + pub fn set_default_icon(&self, scope: Scope, icon: Option<&IconResVariant>) -> Result<(), Error> { todo!() } const NAMEOF_FRIENDLY_APP_NAME: &str = "FriendlyAppName"; - pub fn get_friendly_app_name(&self, view: View) -> Result, Error> { + pub fn get_friendly_app_name(&self, view: View) -> Result, Error> { todo!() } - pub fn set_friendly_app_name(&self, scope: Scope, name: Option<&LosseStrRefStr>) -> Result<(), Error> { + pub fn set_friendly_app_name(&self, scope: Scope, name: Option<&StrResVariant>) -> Result<(), Error> { todo!() }