diff --git a/crates/model/src/pipe/color.rs b/crates/model/src/pipe/color.rs index be729c2..89867f2 100644 --- a/crates/model/src/pipe/color.rs +++ b/crates/model/src/pipe/color.rs @@ -1,5 +1,4 @@ use std::ops::Range; -use std::str::FromStr; #[derive(Clone, Copy)] pub struct Color { @@ -90,19 +89,6 @@ pub enum ColorMode { None, } -impl FromStr for ColorMode { - type Err = anyhow::Error; - - fn from_str(s: &str) -> Result { - Ok(match s { - "ansi" => Self::Ansi, - "rgb" => Self::Rgb, - "none" => Self::None, - _ => anyhow::bail!(r#"unknown color mode (expected “ansi”, “rgb”, or “none”)"#), - }) - } -} - #[derive(Clone, Copy, serde::Serialize, serde::Deserialize)] #[serde(rename_all = "snake_case")] pub enum Palette { @@ -112,22 +98,6 @@ pub enum Palette { Matrix, } -impl FromStr for Palette { - type Err = anyhow::Error; - - fn from_str(s: &str) -> Result { - Ok(match s { - "default" => Self::Default, - "darker" => Self::Darker, - "pastel" => Self::Pastel, - "matrix" => Self::Matrix, - _ => anyhow::bail!( - r#"unknown palette (expected “default”, “darker”, “pastel”, or “matrix”)"# - ), - }) - } -} - impl Palette { pub(super) fn get_hue_range(self) -> Range { match self { diff --git a/crates/model/src/pipe/kind.rs b/crates/model/src/pipe/kind.rs index 3db438c..b8a5be0 100644 --- a/crates/model/src/pipe/kind.rs +++ b/crates/model/src/pipe/kind.rs @@ -86,27 +86,6 @@ enum KindWidth { Custom(NonZeroUsize), } -impl FromStr for Kind { - type Err = anyhow::Error; - - fn from_str(s: &str) -> Result { - Ok(match s { - "heavy" => Self::Heavy, - "light" => Self::Light, - "curved" => Self::Curved, - "knobby" => Self::Knobby, - "emoji" => Self::Emoji, - "outline" => Self::Outline, - "dots" => Self::Dots, - "blocks" => Self::Blocks, - "sus" => Self::Sus, - _ => anyhow::bail!( - r#"unknown pipe kind (expected “heavy”, “light”, “curved”, “knobby”, “emoji”, “outline”, “dots”, “blocks”, or “sus”)"#, - ), - }) - } -} - #[derive(serde::Serialize, serde::Deserialize, Clone)] pub struct KindSet(Vec); @@ -117,7 +96,20 @@ impl FromStr for KindSet { let mut set = Vec::new(); for kind in s.split(',') { - let kind = Kind::from_str(kind)?; + let kind = match kind { + "heavy" => Kind::Heavy, + "light" => Kind::Light, + "curved" => Kind::Curved, + "knobby" => Kind::Knobby, + "emoji" => Kind::Emoji, + "outline" => Kind::Outline, + "dots" => Kind::Dots, + "blocks" => Kind::Blocks, + "sus" => Kind::Sus, + _ => anyhow::bail!( + r#"unknown pipe kind (expected “heavy”, “light”, “curved”, “knobby”, “emoji”, “outline”, “dots”, “blocks”, or “sus”)"#, + ), + }; if !set.contains(&kind) { set.push(kind);