Skip to main content

EnvAccess

Trait EnvAccess 

Source
pub trait EnvAccess {
    // Required method
    fn env_provider(&self) -> &dyn EnvProvider;

    // Provided methods
    fn env(&self, key: &str) -> Option<String> { ... }
    fn env_or(&self, key: &str, default: &str) -> String { ... }
    fn env_require(&self, key: &str) -> Result<String> { ... }
    fn env_parse<T: FromStr>(&self, key: &str) -> Result<T>
       where T::Err: Display { ... }
    fn env_parse_or<T: FromStr>(&self, key: &str, default: T) -> Result<T>
       where T::Err: Display { ... }
    fn env_contains(&self, key: &str) -> bool { ... }
}
Expand description

Extension methods for environment variable access on contexts.

Required Methods§

Provided Methods§

Source

fn env(&self, key: &str) -> Option<String>

Source

fn env_or(&self, key: &str, default: &str) -> String

Source

fn env_require(&self, key: &str) -> Result<String>

Source

fn env_parse<T: FromStr>(&self, key: &str) -> Result<T>
where T::Err: Display,

Source

fn env_parse_or<T: FromStr>(&self, key: &str, default: T) -> Result<T>
where T::Err: Display,

Returns the default when unset; errors only if the variable is set but unparseable.

Source

fn env_contains(&self, key: &str) -> bool

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§