added target form

This commit is contained in:
euzu
2025-11-03 21:19:35 +01:00
parent 6ed1829636
commit f432e215ff
45 changed files with 1490 additions and 556 deletions
+29
View File
@@ -1,4 +1,5 @@
use std::fmt::Display;
use std::str::FromStr;
use enum_iterator::Sequence;
#[derive(Debug, Copy, Clone, serde::Serialize, serde::Deserialize, Sequence, PartialEq, Eq, Default)]
@@ -38,4 +39,32 @@ impl Display for ProcessingOrder {
Self::Mrf => Self::MRF,
})
}
}
impl FromStr for ProcessingOrder {
type Err = &'static str;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let normalized = s.trim().to_lowercase();
match normalized.as_str() {
// Short codes
"frm" => Ok(Self::Frm),
"fmr" => Ok(Self::Fmr),
"rfm" => Ok(Self::Rfm),
"rmf" => Ok(Self::Rmf),
"mfr" => Ok(Self::Mfr),
"mrf" => Ok(Self::Mrf),
// Accept the exact Display text (using your constants)
x if x == Self::FRM => Ok(Self::Frm),
x if x == Self::FMR => Ok(Self::Fmr),
x if x == Self::RFM => Ok(Self::Rfm),
x if x == Self::RMF => Ok(Self::Rmf),
x if x == Self::MFR => Ok(Self::Mfr),
x if x == Self::MRF => Ok(Self::Mrf),
_ => Err("invalid processing order"),
}
}
}