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