pub struct ConfigKey { /* private fields */ }
Expand description
Key for a configuration variable.
This type represents a configuration variable that we’re looking up in Cargo’s configuration. This structure simultaneously keeps track of a corresponding environment variable name as well as a TOML config name. The intention here is that this is built up and torn down over time efficiently, avoiding clones and such as possible.
Implementations
sourceimpl ConfigKey
impl ConfigKey
sourcepub fn new() -> ConfigKey
pub fn new() -> ConfigKey
Creates a new blank configuration key which is ready to get built up by
using push
and push_sensitive
.
sourcepub fn from_str(key: &str) -> ConfigKey
pub fn from_str(key: &str) -> ConfigKey
Creates a ConfigKey
from the key
specified.
The key
specified is expected to be a period-separated toml
configuration key.
sourcepub fn push(&mut self, name: &str)
pub fn push(&mut self, name: &str)
Pushes a new sub-key on this ConfigKey
. This sub-key should be
equivalent to accessing a sub-table in TOML.
Note that this considers name
to be case-insensitive, meaning that the
corrseponding toml key is appended with this name
as-is and the
corresponding env key is appended with name
after transforming it to
uppercase characters.
sourcepub fn push_sensitive(&mut self, name: &str)
pub fn push_sensitive(&mut self, name: &str)
Performs the same function as push
except that the corresponding
environment variable does not get the uppercase letters of name
but
instead name
is pushed raw onto the corresponding environment
variable.
sourcepub fn pop(&mut self)
pub fn pop(&mut self)
Rewinds this ConfigKey
back to the state it was at before the last
push
method being called.
sourcepub fn as_env_key(&self) -> &str
pub fn as_env_key(&self) -> &str
Returns the corresponding environment variable key for this configuration value.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for ConfigKey
impl Send for ConfigKey
impl Sync for ConfigKey
impl Unpin for ConfigKey
impl UnwindSafe for ConfigKey
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more