env_type::types

Trait EnvKey

source
pub trait EnvKey {
    // Required method
    fn key() -> &'static str;
}
Expand description

EnvKey is a trait that represents the environment key.

§Example

use env_type::types::{EnvType, EnvKey};
use std::str::FromStr;

struct NewEnvKey;

impl EnvKey for NewEnvKey {
   fn key() -> &'static str {
      "NEW_ENV"
  }
}

std::env::set_var("NEW_ENV", "Production");
let env = EnvType::from_env_key::<NewEnvKey>();
assert_eq!(EnvType::Prod, env);

Required Methods§

source

fn key() -> &'static str

Object Safety§

This trait is not object safe.

Implementors§

source§

impl EnvKey for EnvType

EnvType is an implementation of the EnvKey trait. The default environment key is “ENV”.