refactor: use single unified syntax shim type instead of many
This commit is contained in:
parent
ed6cdd02f7
commit
db6c758a73
1 changed files with 102 additions and 92 deletions
64
sabry_intrnl/src/syntax/ostrta.rs
Normal file
64
sabry_intrnl/src/syntax/ostrta.rs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/// Convenience unification entrypoint
|
||||
/// to make friends with all the different syntax-consumers
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum OneSyntaxToRuleThemAll {
|
||||
Sass,
|
||||
Scss
|
||||
}
|
||||
|
||||
impl Default for OneSyntaxToRuleThemAll {
|
||||
fn default() -> Self {
|
||||
Self::Scss
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<&str> for OneSyntaxToRuleThemAll {
|
||||
type Error = ();
|
||||
fn try_from(value: &str) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
"sass" => Ok(Self::Sass),
|
||||
"scss" => Ok(Self::Scss),
|
||||
_ => Err(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<raffia::Syntax> for OneSyntaxToRuleThemAll {
|
||||
type Error = ();
|
||||
fn try_from(value: raffia::Syntax) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
raffia::Syntax::Sass => Ok(Self::Sass),
|
||||
raffia::Syntax::Scss => Ok(Self::Scss),
|
||||
_ => Err(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<grass::InputSyntax> for OneSyntaxToRuleThemAll {
|
||||
type Error = ();
|
||||
fn try_from(value: grass::InputSyntax) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
grass::InputSyntax::Sass => Ok(Self::Sass),
|
||||
grass::InputSyntax::Scss => Ok(Self::Scss),
|
||||
_ => Err(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<OneSyntaxToRuleThemAll> for raffia::Syntax {
|
||||
fn from(value: OneSyntaxToRuleThemAll) -> Self {
|
||||
match value {
|
||||
OneSyntaxToRuleThemAll::Sass => Self::Sass,
|
||||
OneSyntaxToRuleThemAll::Scss => Self::Scss
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<OneSyntaxToRuleThemAll> for grass::InputSyntax {
|
||||
fn from(value: OneSyntaxToRuleThemAll) -> Self {
|
||||
match value {
|
||||
OneSyntaxToRuleThemAll::Scss => Self::Scss,
|
||||
OneSyntaxToRuleThemAll::Sass => Self::Sass
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue