Skip to main content

Env

Trait Env 

pub trait Env:
    Debug
    + Send
    + Sync
    + 'static {
    // Required methods
    fn var(&self, key: &str) -> Option<String>;
    fn vars(&self) -> HashMap<String, String>;
    fn home_dir(&self) -> Option<PathBuf>;
}
Available on crate feature reqsign only.
Expand description

Permits parameterizing the home functions via the _from variants

Required Methods§

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

Get an environment variable.

  • Returns Some(v) if the environment variable is found and is valid utf-8.
  • Returns None if the environment variable is not found or value is invalid.

fn vars(&self) -> HashMap<String, String>

Returns a hashmap of (variable, value) pairs of strings, for all the environment variables of the current process.

fn home_dir(&self) -> Option<PathBuf>

Return the path to the users home dir, returns None if any error occurs.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

§

impl Env for NoopEnv

§

impl Env for OsEnv

§

impl Env for StaticEnv