pub struct EnvVar {
pub name: &'static str,
pub kind: EnvKind,
pub owner: Owner,
pub default: &'static str,
pub summary: &'static str,
}Expand description
One environment variable the reader reads.
Fields§
§name: &'static strThe variable name as it appears in the environment.
kind: EnvKindWhat the value means and how it is parsed.
owner: OwnerWho owns the value space.
default: &'static strWhat happens when the variable is unset.
summary: &'static strOne line an embedder can read to know whether they care.
Implementations§
Source§impl EnvVar
impl EnvVar
Sourcepub fn count_or(&self, default: usize) -> usize
pub fn count_or(&self, default: usize) -> usize
Read this variable as a count, falling back to default.
A value that is not a number is not a smaller number: it is a mistake, and the default is a better answer than a silently-wrong one.
Sourcepub fn millis_or(&self, default: Duration) -> Duration
pub fn millis_or(&self, default: Duration) -> Duration
Read this variable as a millisecond duration, falling back to default.
Sourcepub fn is_present(&self) -> bool
pub fn is_present(&self) -> bool
Whether the variable is present at all, whatever its value – including
empty or 0.
Several older switches are read this way, and narrowing them to
recognised spellings would turn =0 from “on” into “off” for anyone who
already relies on it. It is a method rather than an EnvKind variant
because EnvKind is public and exhaustive: adding a variant would break
a downstream match in a 4.x release.
Sourcepub fn os(&self) -> Option<OsString>
pub fn os(&self) -> Option<OsString>
Read this variable exactly as the host wrote it.
Unlike EnvVar::path an empty value is still Some: some readers
have always treated VAR= as set, and this keeps them doing so.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EnvVar
impl RefUnwindSafe for EnvVar
impl Send for EnvVar
impl Sync for EnvVar
impl Unpin for EnvVar
impl UnsafeUnpin for EnvVar
impl UnwindSafe for EnvVar
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more