VarEnv

Struct VarEnv 

Source
pub struct VarEnv<N: Eq + Hash, V> { /* private fields */ }
Expand description

An environment module for setting, getting, and exporting shell variables.

Implementations§

Source§

impl<N, V> VarEnv<N, V>
where N: Eq + Hash,

Source

pub fn new() -> Self

Constructs a new environment with no environment variables.

Source

pub fn with_process_env_vars() -> Self
where N: From<String>, V: From<String>,

Constructs a new environment and initializes it with the environment variables of the current process.

Source

pub fn with_env_vars<I: IntoIterator<Item = (N, V)>>(iter: I) -> Self

Constructs a new environment with a provided collection of (key, value) environment variable pairs. These variables (if any) will be inherited by all commands.

Trait Implementations§

Source§

impl<N, V> Clone for VarEnv<N, V>
where N: Eq + Hash,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<N, V> Debug for VarEnv<N, V>
where N: Eq + Ord + Hash + Debug, V: Debug,

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<N, V> Default for VarEnv<N, V>
where N: Eq + Hash,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<N, V> ExportedVariableEnvironment for VarEnv<N, V>
where N: Eq + Clone + Hash, V: Eq + Clone,

Source§

fn exported_var(&self, name: &Self::VarName) -> Option<(&Self::Var, bool)>

Get the value of some variable and whether it is exported.
Source§

fn set_exported_var( &mut self, name: Self::VarName, val: Self::Var, exported: bool, )

Set the value of some variable, and set it’s exported status as specified.
Source§

impl<N: PartialEq + Eq + Hash, V: PartialEq> PartialEq for VarEnv<N, V>

Source§

fn eq(&self, other: &VarEnv<N, V>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<N, V> SubEnvironment for VarEnv<N, V>
where N: Eq + Hash,

Source§

fn sub_env(&self) -> Self

Create a new sub-environment, which starts out idential to its parent, but any changes on the new environment will not be reflected on the parent.
Source§

impl<N, V> UnsetVariableEnvironment for VarEnv<N, V>
where N: Eq + Clone + Hash, V: Eq + Clone,

Source§

fn unset_var(&mut self, name: &N)

Unset the value of some variable (including environment variables).
Source§

impl<N, V> VariableEnvironment for VarEnv<N, V>
where N: Eq + Clone + Hash, V: Eq + Clone,

Source§

type VarName = N

The type of the name this environment associates for a variable.
Source§

type Var = V

The type of variables this environment holds.
Source§

fn var<Q>(&self, name: &Q) -> Option<&Self::Var>
where Self::VarName: Borrow<Q>, Q: Hash + Eq + ?Sized,

Get the value of some variable. The values of both shell-only and environment variables will be looked up and returned.
Source§

fn set_var(&mut self, name: Self::VarName, val: Self::Var)

Set the value of some variable, maintaining its status as an environment variable if previously set as such.
Source§

fn env_vars(&self) -> Cow<'_, [(&Self::VarName, &Self::Var)]>

Unset the value of some variable (including environment variables). Get all current pairs of environment variables and their values.
Source§

impl<N: Eq + Eq + Hash, V: Eq> Eq for VarEnv<N, V>

Source§

impl<N: Eq + Hash, V> StructuralPartialEq for VarEnv<N, V>

Auto Trait Implementations§

§

impl<N, V> Freeze for VarEnv<N, V>

§

impl<N, V> RefUnwindSafe for VarEnv<N, V>

§

impl<N, V> Send for VarEnv<N, V>
where N: Sync + Send, V: Sync + Send,

§

impl<N, V> Sync for VarEnv<N, V>
where N: Sync + Send, V: Sync + Send,

§

impl<N, V> Unpin for VarEnv<N, V>

§

impl<N, V> UnwindSafe for VarEnv<N, V>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.