Trait FromEnv

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

    // Required method
    fn from_env() -> Result<Self, FromEnvErr<Self::Error>>;
}
Expand description

Trait for loading from the environment.

This trait is for structs or other complex objects, that need to be loaded from the environment. It expects that

  • The struct is Sized and 'static.
  • The struct elements can be parsed from strings.
  • Struct elements are at fixed env vars, known by the type at compile time.

As such, unless the env is modified, these are essentially static runtime values.

Required Associated Types§

Source

type Error: Error

Error type produced when loading from the environment.

Required Methods§

Source

fn from_env() -> Result<Self, FromEnvErr<Self::Error>>

Load from the environment.

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.

Implementors§