Skip to main content

Env

Trait Env 

Source
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>;
}
Expand description

Permits parameterizing the home functions via the _from variants

Required Methods§

Source

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.
Source

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

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

Source

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§