mr_env_plus 0.1.0

Environment configuration management for Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use mr_env_plus::EnvConfig;
#[derive(EnvConfig, Debug)]
pub struct Config {
    #[env(name = "APP_NAME", required = true)]
    pub app_name: String,

    #[env(name = "APP_PORT", default = "8080")]
    pub port: u16,

    #[env(name = "DEBUG_MODE", default = "false")]
    pub debug: bool,
}

fn main() {
    mr_env_plus::init_with(".env").ok();
    let config = Config::from_env();
    println!("Config with path: {:?}", config);
}