Expand description
serde-env will allow deserializing env into structs.
The biggest different between envy is
serde-env supports deserialize _
separated env into nests structs. That means
we will treat env as _
separated tree instead of a flat map.
For examples:
use serde::Deserialize;
use serde_env::from_env;
#[derive(Debug, Deserialize)]
struct Cargo {
home: String,
}
#[derive(Debug, Deserialize)]
struct Test {
#[cfg(windows)]
#[serde(rename = "userprofile")]
home: String,
#[cfg(not(windows))]
home: String,
cargo: Cargo,
}
let t: Test = from_env().expect("deserialize from env");
assert!(!t.home.is_empty());
assert!(!t.cargo.home.is_empty());
println!("{:?}", t)
Re-exports§
pub use error::Error;
Modules§
Functions§
- Deserialize into struct via env.
- Deserialize into struct via env with a prefix.
- Deserialize into struct via an iterable of
(AsRef<str>, AsRef<str>)
representing keys and values. - Deserialize into struct via an iterable of
(AsRef<str>, AsRef<str>)
representing keys and values, with a prefix.