Enum cnf::env::Env

source ·
pub enum Env {
    AliasPrivileged,
    AliasExecutable,
    RecursionDepth,
    LogLevel,
}
Expand description

Application-wide environment variables.

Variants§

§

AliasPrivileged

If this variable is defined, an alias is executed with elevated privileges.

§

AliasExecutable

Name or absolute path of the cnf executable to resolve aliases with.

This is only used when resolving aliases and can be used to override the cnf version e.g. for development purposes to test newer features, like so:

$ CNF_ALIAS_EXECUTABLE="$PWD/target/debug/cnf" podman image ls
§

RecursionDepth

Set by the application to keep track of how many recursion levels are currently used by e.g. alias execution.

§

LogLevel

Overwrite the log level set in the application configuration.

Adheres roughly to env_logger syntax, see here: https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives

Implementations§

source§

impl Env

source

pub fn is_set(&self) -> bool

Returns true if an environment variable is defined and set to an arbitrary value.

source

pub fn get_raw(&self) -> Option<OsString>

Get the raw value of an environment variable. Refer to std::env::var_os for what a value of None may mean.

source

pub fn set_raw(&self, value: impl AsRef<OsStr>)

Set the raw value of an environment variable.

source

pub fn get<T: FromStr>(&self) -> Option<T>

Read an environment variable to a concrete type, if possible. Returns None if either:

  • Env::get returns None
  • The variable value cannot be parsed into a valid UTF-8 string
  • The variable value cannot be parsed into the requested type
source

pub fn set<T: Display>(&self, value: T)

Set an environment variable to the string representation of value.

Trait Implementations§

source§

impl Debug for Env

source§

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

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

impl Display for Env

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Env

§

impl Send for Env

§

impl Sync for Env

§

impl Unpin for Env

§

impl UnwindSafe for Env

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

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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

§

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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more