mirror of
https://github.com/euzu/tuliprox.git
synced 2026-10-21 23:32:39 +02:00
added target form
This commit is contained in:
@@ -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"),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user