Trait FromEnvVar

Source
pub trait FromEnvVar:
    Debug
    + Sized
    + 'static {
    type Error: Error;

    // Required method
    fn from_env_var(env_var: &str) -> Result<Self, FromEnvErr<Self::Error>>;
}
Expand description

Trait for loading primitives from the environment. These are simple types that should correspond to a single environment variable. It has been implemented for common integer types, String, url::Url, tracing::Level, and std::time::Duration.

It aims to make FromEnv implementations easier to write, by providing a default implementation for common types.

Required Associated Types§

Source

type Error: Error

Error type produced when parsing the primitive.

Required Methods§

Source

fn from_env_var(env_var: &str) -> Result<Self, FromEnvErr<Self::Error>>

Load the primitive from the environment at the given variable.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl FromEnvVar for i8

Source§

impl FromEnvVar for i16

Source§

impl FromEnvVar for i32

Source§

impl FromEnvVar for i64

Source§

impl FromEnvVar for i128

Source§

impl FromEnvVar for isize

Source§

impl FromEnvVar for u8

Source§

impl FromEnvVar for u16

Source§

impl FromEnvVar for u32

Source§

impl FromEnvVar for u64

Source§

impl FromEnvVar for u128

Source§

impl FromEnvVar for usize

Source§

impl FromEnvVar for String

Source§

impl FromEnvVar for Duration

Source§

impl FromEnvVar for Level

Source§

impl FromEnvVar for Url

Implementors§