Skip to main content

EnvroConfig

Trait EnvroConfig 

Source
pub trait EnvroConfig: Sized {
    // Required methods
    fn schema() -> Schema;
    fn from_vars(vars: &EnvroVars) -> Result<Self, EnvroError>;
    fn from_env() -> Result<Self, EnvroError>;

    // Provided method
    fn from_dotenv(path: &Path) -> Result<Self, EnvroError> { ... }
}
Expand description

Typed config loaded from env vars via #[derive(Envro)].

The derive encodes field types and validation rules only; values are always read at runtime from a map, a .env file, or the process environment.

Required Methods§

Source

fn schema() -> Schema

Schema generated from field types and #[envro(...)] attributes.

Source

fn from_vars(vars: &EnvroVars) -> Result<Self, EnvroError>

Validate and coerce from an in-memory map.

Source

fn from_env() -> Result<Self, EnvroError>

Read schema keys from the process environment, then coerce.

Provided Methods§

Source

fn from_dotenv(path: &Path) -> Result<Self, EnvroError>

Load a .env file, then from_vars.

With feature encryption, #[envro(secret)] fields must be Encrypted[AGE:b64:…] in the file (checked before decrypt via load_dotenv_validated).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§