Expand description
Parse environment variables into type-safe structures.
use tenvy::Tenvy;
#[derive(Debug, Tenvy)]
struct Environment {
database_url: String,
server: Server,
}
#[derive(Debug, Tenvy)]
struct Server {
addr: std::net::SocketAddr,
workers: Option<std::num::NonZeroUsize>,
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let env: Environment = tenvy::from_env()?;
println!("{env:#?}");
Ok(())
}Structs§
- Env
- Current context of environment variable parsing.
- From
- Adapter that parses
Uand then transforms it intoTusingFrom. - FromStr
- Adapter that parses
Tusing itsFromStrimplementation. - TryFrom
- Adapter that parses
Uand then transforms it intoTusingTryFrom.
Enums§
- Error
- An error during parsing of environment variables.
Traits§
- Tenvy
- Parse a value from environment variables.
Functions§
- from_
env - Parse environment variables into
T.