envious 0.1.0

Deserialize (potentially nested) environment variables into your custom structs
Documentation

envious cover image

Bors enabled Crates.io Docs.rs

envious allows you to deserialize your serde enabled structs from environment variables.

See it in action:

use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug)]
enum StaircaseOrientation {
    Left,
    Right,
}

#[derive(Serialize, Deserialize, Debug)]
struct Config {
    target_temp: f32,
    automate_doors: bool,

    staircase_orientation: StaircaseOrientation,
}

let config: Config = envious::from_env(envious::Prefix::None).expect("Could not deserialize from env");

With the following environment variables:

EXPORT target_temp=25.0
EXPORT automate_doors=true
EXPORT staircase_orientation=Left

it will parse it from the environment and give you a Rust struct you can use in your application.

Note: The environment variables are case sensitive! This is due to how serde works internally. If you want your structs to use SCREAMING_SNAKE_CASE, then be sure to use the #[serde(rename_all = "SCREAMING_SNAKE_CASE"] annotation on all concerned structs.

License

envious is licensed under MIT or Apache 2.0, as you wish.

Contributing

To contribute to envious you can:

  • Open up issues with ideas, remarks, bug reports, etc...
  • Fork and implement new features and send them in as pull requests
  • Leave it a Star and spread the word! ;)