pub trait AsEnvTypeStr {
// Required method
fn as_env_type_str(&self) -> Option<String>;
}Expand description
AsEnvTypeStr is a trait that covert some type to a string, which is the environment type. This trait can extend the existing configuration struct to get the environment type.
§Example
use env_type::types::{EnvType, AsEnvTypeStr};
struct Config {
env_str: String,
}
impl AsEnvTypeStr for Config {
fn as_env_type_str(&self) -> Option<String> {
Some(self.env_str.clone())
}
}
let config = Config {
env_str: "dev".to_string(),
};
assert_eq!("dev", config.as_env_type_str().unwrap());