Skip to main content

EnvironmentSpec

Struct EnvironmentSpec 

Source
pub struct EnvironmentSpec { /* private fields */ }
Expand description

Environment construction rules for a command.

Overrides are kept in a sorted map for deterministic inspection and are applied by a backend after selecting the requested base environment. A value of EnvironmentOverride::Remove is distinct from setting an empty string. Variable names are one logical, case-insensitive namespace, so a later case variant replaces an earlier override.

Implementations§

Source§

impl EnvironmentSpec

Source

pub fn inherit_all() -> Self

Creates an environment that inherits all parent variables.

Source

pub fn empty() -> Self

Creates an environment that starts empty.

Source

pub fn inherit_core() -> Self

Creates an environment that inherits the platform’s core variables.

Source

pub fn base(&self) -> EnvironmentBase

Returns the selected base environment behavior.

Source

pub fn overrides(&self) -> &BTreeMap<OsString, EnvironmentOverride>

Returns all explicit variable overrides in deterministic key order.

The spelling of a name is retained for backend diagnostics, but names are one case-insensitive logical namespace for lookup and equality.

Source

pub fn filters(&self) -> &BTreeMap<EnvironmentPattern, EnvironmentFilterAction>

Returns canonical environment filters in deterministic pattern order.

Source

pub fn override_for(&self, name: &OsStr) -> Option<&EnvironmentOverride>

Returns the override for one variable, if present.

Source

pub fn filter_action_for(&self, name: &str) -> Option<EnvironmentFilterAction>

Returns the filter action for a variable name, if a filter matches.

Exclude always wins when both actions match. A backend can use the presence of any include filter together with this result to implement the complete inherited-environment decision without reimplementing wildcard precedence.

Source

pub fn apply_to( &self, input: EnvironmentInput, ) -> Result<EnvironmentInput, CommandError>

Applies filters and explicit overrides to an already selected base environment.

The caller selects the All, Core, or None base at the backend boundary. A broader input is rejected before transformation. This method then applies the portable sequence exclude -> set/remove -> include and keeps the validated base tag on the returned snapshot. A variable removed by an exclude is not restored by an include; an explicit set is applied after exclusion and can intentionally reintroduce that named variable.

Source

pub fn with_var( self, name: impl Into<OsString>, value: impl Into<OsString>, ) -> Result<Self, CommandError>

Adds a variable assignment and returns the updated environment.

Source

pub fn without_var( self, name: impl Into<OsString>, ) -> Result<Self, CommandError>

Adds a variable removal and returns the updated environment.

Source

pub fn with_filter( self, pattern: impl Into<String>, action: EnvironmentFilterAction, ) -> Result<Self, CommandError>

Adds or replaces a canonical environment filter.

Source

pub fn with_include_pattern( self, pattern: impl Into<String>, ) -> Result<Self, CommandError>

Adds an include filter.

Source

pub fn with_exclude_pattern( self, pattern: impl Into<String>, ) -> Result<Self, CommandError>

Adds an exclude filter.

Trait Implementations§

Source§

impl Clone for EnvironmentSpec

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for EnvironmentSpec

Source§

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

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

impl Default for EnvironmentSpec

Source§

fn default() -> Self

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

impl Eq for EnvironmentSpec

Source§

impl PartialEq for EnvironmentSpec

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more

Auto Trait Implementations§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.