doido_controller/
environment.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum Environment {
6 Development,
7 Test,
8 Production,
9}
10
11impl Environment {
12 pub fn get_env() -> Environment {
17 match std::env::var("DOIDO_ENV").as_deref() {
18 Ok("production") => Environment::Production,
19 Ok("test") => Environment::Test,
20 _ => Environment::Development,
21 }
22 }
23
24 pub fn as_str(&self) -> &'static str {
26 match self {
27 Environment::Development => "development",
28 Environment::Test => "test",
29 Environment::Production => "production",
30 }
31 }
32}
33
34impl std::fmt::Display for Environment {
35 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
36 f.write_str(self.as_str())
37 }
38}