Skip to main content

EnvLayer

Struct EnvLayer 

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

Settings read from environment variables.

Implementations§

Source§

impl EnvLayer

Source

pub fn from_process() -> Self

The variables this process was started with.

std::env::vars panics on a name or value that is not UTF-8, which would take the CLI down before it resolved anything — over a variable that in all likelihood belongs to something else entirely. Read as OS strings and skipped when they will not convert: a setting whose variable holds bytes this cannot read has no value it could have been given anyway.

Source

pub fn new(vars: impl IntoIterator<Item = (String, String)>) -> Self

A named environment, for a test or for a CLI that has its own idea of one.

Source

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

What this layer would read for name, if anything.

Trait Implementations§

Source§

impl Layer for EnvLayer

Source§

fn source(&self) -> SourceKind

Which kind of place this reads. Used by the scope check and reported by explain.
Source§

fn load(&self, ctx: &LayerCtx) -> Result<LayerOutput, LayerError>

Everything this layer has to say, in one pass.

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