Skip to main content

EnvironmentDeclaration

Struct EnvironmentDeclaration 

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

The environment pass-through allow-list a document declares: variable NAMES, in the order they were written.

Order is preserved because it is the operator’s own; duplicates are preserved for the same reason and collapse when the environment is built, where a later name simply resolves to the same value. Nothing here reads a value: this is the declaration, and Self::resolve is where it meets a launching context.

Implementations§

Source§

impl EnvironmentDeclaration

Source

pub fn new( names: impl IntoIterator<Item = impl Into<String>>, ) -> Result<Self, EnvironmentError>

The declaration carrying names.

§Errors

Returns EnvironmentError::EmptyName for a blank entry and EnvironmentError::NameContainsEquals for a KEY=VALUE pair — the two ways an entry can look like a declaration without being one.

Source

pub fn empty() -> Self

The declaration naming NO variable.

Infallible, because there is no entry to be malformed. A child launched under it gets a genuinely empty environment, which is a coherent thing for an absolute command that needs nothing at all.

It is reachable only from a hand-written composition root, and that is deliberate rather than an oversight in the grammar: a worker DOCUMENT cannot express it, because env_pass takes one or more names and there is no spelling for none. An empty list in a file is indistinguishable from an unfinished line, and the cost of reading one as the other is an agent launched with no PATH, no HOME and no credentials, failing three layers down for a reason nobody wrote. A caller constructing this in code has stated it unambiguously; an author typing it into a document has not. If the hermetic-empty case is ever wanted from a document it needs its own explicit spelling, not a permissive reading of an empty list.

Source

pub fn names(&self) -> &[String]

The declared names, in the order they were written.

Source

pub fn resolve(&self, context: &BTreeMap<String, String>) -> ChildEnvironment

Resolves the declaration against context — a snapshot of the launching process’s environment — into the exact, total environment a child receives.

A declared name absent from context contributes NO variable: an unset variable and a variable set to the empty string are different things, and inventing one for the other would be a value nobody wrote. Which names came up absent is kept on the result so a launcher can say so rather than leave the operator guessing.

Source

pub fn resolve_from_process(&self) -> ChildEnvironment

Resolves the declaration against THIS process’s environment.

The launching context of a worker that spawns its own harness children. Non-UTF-8 names and values are skipped rather than lossily transcoded: a mangled credential is worse than an absent one, and an absent one is reported.

Trait Implementations§

Source§

impl Clone for EnvironmentDeclaration

Source§

fn clone(&self) -> EnvironmentDeclaration

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 EnvironmentDeclaration

Source§

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

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

impl Eq for EnvironmentDeclaration

Source§

impl PartialEq for EnvironmentDeclaration

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for EnvironmentDeclaration

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> Same for T

Source§

type Output = T

Should always be Self
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, <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.