-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: feature and experimental feature flags (#448)
* feat: feature and experimental feature flags * chore: clippy * fix: review --------- Co-authored-by: Danny Browning <dbrowning@3box.io>
- Loading branch information
Showing
3 changed files
with
88 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use anyhow::{anyhow, Result}; | ||
|
||
#[derive(Clone, Debug, PartialEq)] | ||
pub(crate) enum ExperimentalFeatureFlags { | ||
None, | ||
Authentication, | ||
} | ||
|
||
impl std::str::FromStr for ExperimentalFeatureFlags { | ||
type Err = anyhow::Error; | ||
|
||
fn from_str(value: &str) -> Result<Self> { | ||
match value.to_ascii_lowercase().as_str() { | ||
"none" => Ok(ExperimentalFeatureFlags::None), | ||
"authentication" => Ok(ExperimentalFeatureFlags::Authentication), | ||
_ => Err(anyhow!("invalid value")), | ||
} | ||
} | ||
} | ||
|
||
impl std::fmt::Display for ExperimentalFeatureFlags { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
ExperimentalFeatureFlags::None => write!(f, "none"), | ||
ExperimentalFeatureFlags::Authentication => write!(f, "authentication"), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq)] | ||
pub(crate) enum FeatureFlags { | ||
None, | ||
} | ||
|
||
impl std::fmt::Display for FeatureFlags { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
FeatureFlags::None => write!(f, "none"), | ||
} | ||
} | ||
} | ||
|
||
impl std::str::FromStr for FeatureFlags { | ||
type Err = anyhow::Error; | ||
|
||
fn from_str(value: &str) -> Result<Self> { | ||
match value.to_ascii_lowercase().as_str() { | ||
"none" => Ok(FeatureFlags::None), | ||
_ => Err(anyhow!("invalid value")), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters