pub struct ConfigKey {
env: String,
parts: Vec<(String, usize)>,
}
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.
Fields§
§env: String
§parts: Vec<(String, usize)>
Implementations§
source§impl 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
corresponding 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.
fn _push(&mut self, env: &str, config: &str)
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§
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> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 48 bytes