#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Environment {
Development,
Test,
Production,
}
impl Environment {
pub fn get_env() -> Environment {
match std::env::var("DOIDO_ENV").as_deref() {
Ok("production") => Environment::Production,
Ok("test") => Environment::Test,
_ => Environment::Development,
}
}
pub fn as_str(&self) -> &'static str {
match self {
Environment::Development => "development",
Environment::Test => "test",
Environment::Production => "production",
}
}
}
impl std::fmt::Display for Environment {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}