pub struct EnvVariableName(/* private fields */);Expand description
Validated environment variable name.
Ensures the name is non-empty and does not contain =.
Implementations§
Source§impl EnvVariableName
impl EnvVariableName
pub fn as_str(&self) -> &str
Sourcepub const fn from_static_or_panic(name: &'static str) -> Self
pub const fn from_static_or_panic(name: &'static str) -> Self
Validated environment variable name for 'static inputs.
§Panics
Panics at compile time when used in a const context, or at runtime otherwise,
if the name is empty or contains =.
Sourcepub fn read(&self) -> Result<EnvVariableValue, EnvVariableReadError>
pub fn read(&self) -> Result<EnvVariableValue, EnvVariableReadError>
Reads this variable from the current process environment.
§Errors
Returns EnvVariableReadError when the variable is absent, holds a
non-unicode value, or holds a value that fails EnvVariableValue
validation.
Sourcepub fn is_present(&self) -> bool
pub fn is_present(&self) -> bool
Returns whether this variable is set in the current process environment.
Presence is independent of value validity: a value that would fail
EnvVariableValue validation (non-unicode, oversized) still counts as
present.
Sourcepub fn load_from_str<T>(&self) -> Result<T, EnvVariableLoadError<T::Err>>
pub fn load_from_str<T>(&self) -> Result<T, EnvVariableLoadError<T::Err>>
Reads this variable and parses its value via std::str::FromStr.
§Errors
Returns EnvVariableLoadError::Read when the variable cannot be read
(see EnvVariableName::read) or EnvVariableLoadError::Convert when
parsing the value fails.
Sourcepub fn load_try_from<T>(&self) -> Result<T, EnvVariableLoadError<T::Error>>
pub fn load_try_from<T>(&self) -> Result<T, EnvVariableLoadError<T::Error>>
Reads this variable and converts its value via TryFrom<String>.
§Errors
Returns EnvVariableLoadError::Read when the variable cannot be read
(see EnvVariableName::read) or EnvVariableLoadError::Convert when
the conversion fails.
Trait Implementations§
Source§impl AsRef<OsStr> for EnvVariableName
impl AsRef<OsStr> for EnvVariableName
Source§impl Clone for EnvVariableName
impl Clone for EnvVariableName
Source§fn clone(&self) -> EnvVariableName
fn clone(&self) -> EnvVariableName
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more