pub struct ConfigPrefixView<'a> { /* private fields */ }Expand description
Read-only prefix view over a Config: key lookups use a logical key
prefix.
This type is named explicitly so other kinds of configuration views can be
added later without overloading a generic ConfigView.
Lookups rewrite keys by prepending prefix, while exposing keys relative to
that prefix.
Implementations§
Source§impl<'a> ConfigPrefixView<'a>
impl<'a> ConfigPrefixView<'a>
Sourcepub fn prefix(&self) -> &str
pub fn prefix(&self) -> &str
Gets the logical prefix of this view.
§Returns
The normalized prefix string (no leading or trailing dot separators).
Sourcepub fn prefix_view(&self, prefix: &str) -> ConfigPrefixView<'a>
pub fn prefix_view(&self, prefix: &str) -> ConfigPrefixView<'a>
Trait Implementations§
Source§impl<'a> Clone for ConfigPrefixView<'a>
impl<'a> Clone for ConfigPrefixView<'a>
Source§fn clone(&self) -> ConfigPrefixView<'a>
fn clone(&self) -> ConfigPrefixView<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a> ConfigReader for ConfigPrefixView<'a>
impl<'a> ConfigReader for ConfigPrefixView<'a>
Source§fn is_enable_variable_substitution(&self) -> bool
fn is_enable_variable_substitution(&self) -> bool
Returns whether
${...} variable substitution is applied when reading
string values. Read moreSource§fn max_substitution_depth(&self) -> usize
fn max_substitution_depth(&self) -> usize
Returns the maximum recursion depth allowed when resolving nested
${...} references. Read moreSource§fn description(&self) -> Option<&str>
fn description(&self) -> Option<&str>
Returns the optional human-readable description attached to this
configuration (the whole document; prefix views expose the same value
as the underlying
crate::Config).Source§fn len(&self) -> usize
fn len(&self) -> usize
Number of configuration entries visible to this reader (all keys for
crate::Config; relative keys only for a ConfigPrefixView).Source§fn keys(&self) -> Vec<String>
fn keys(&self) -> Vec<String>
All keys visible to this reader (relative keys for a prefix view).
Source§fn contains(&self, name: &str) -> bool
fn contains(&self, name: &str) -> bool
Returns whether a property exists for the given key. Read more
Source§fn get<T>(&self, name: &str) -> ConfigResult<T>where
MultiValues: MultiValuesFirstGetter<T>,
fn get<T>(&self, name: &str) -> ConfigResult<T>where
MultiValues: MultiValuesFirstGetter<T>,
Source§fn get_list<T>(&self, name: &str) -> ConfigResult<Vec<T>>where
MultiValues: MultiValuesGetter<T>,
fn get_list<T>(&self, name: &str) -> ConfigResult<Vec<T>>where
MultiValues: MultiValuesGetter<T>,
Source§fn get_optional<T>(&self, name: &str) -> ConfigResult<Option<T>>where
MultiValues: MultiValuesFirstGetter<T>,
fn get_optional<T>(&self, name: &str) -> ConfigResult<Option<T>>where
MultiValues: MultiValuesFirstGetter<T>,
Gets an optional value with the same semantics as
crate::Config::get_optional. Read moreSource§fn get_optional_list<T>(&self, name: &str) -> ConfigResult<Option<Vec<T>>>where
MultiValues: MultiValuesGetter<T>,
fn get_optional_list<T>(&self, name: &str) -> ConfigResult<Option<Vec<T>>>where
MultiValues: MultiValuesGetter<T>,
Gets an optional list with the same semantics as
crate::Config::get_optional_list. Read moreSource§fn contains_prefix(&self, prefix: &str) -> bool
fn contains_prefix(&self, prefix: &str) -> bool
Returns whether any key visible to this reader starts with
prefix. Read moreSource§fn iter_prefix<'b>(
&'b self,
prefix: &'b str,
) -> Box<dyn Iterator<Item = (&'b str, &'b Property)> + 'b>
fn iter_prefix<'b>( &'b self, prefix: &'b str, ) -> Box<dyn Iterator<Item = (&'b str, &'b Property)> + 'b>
Source§fn iter<'b>(&'b self) -> Box<dyn Iterator<Item = (&'b str, &'b Property)> + 'b>
fn iter<'b>(&'b self) -> Box<dyn Iterator<Item = (&'b str, &'b Property)> + 'b>
Iterates all
(key, property) pairs visible to this reader (same scope
as Self::keys).Source§fn is_null(&self, name: &str) -> bool
fn is_null(&self, name: &str) -> bool
Returns
true if the key exists and the property has no values (same
as crate::Config::is_null).Source§fn subconfig(&self, prefix: &str, strip_prefix: bool) -> ConfigResult<Config>
fn subconfig(&self, prefix: &str, strip_prefix: bool) -> ConfigResult<Config>
Extracts a subtree as a new
Config (same semantics as
crate::Config::subconfig; on a prefix view, prefix is relative to
the view).Source§fn deserialize<T>(&self, prefix: &str) -> ConfigResult<T>where
T: DeserializeOwned,
fn deserialize<T>(&self, prefix: &str) -> ConfigResult<T>where
T: DeserializeOwned,
Deserializes the subtree at
prefix with serde (same as
crate::Config::deserialize; on a prefix view, prefix is relative).Source§fn prefix_view(&self, prefix: &str) -> ConfigPrefixView<'a>
fn prefix_view(&self, prefix: &str) -> ConfigPrefixView<'a>
Creates a read-only prefix view; relative keys resolve under
prefix. Read moreSource§fn resolve_key(&self, name: &str) -> String
fn resolve_key(&self, name: &str) -> String
Source§fn get_or<T>(&self, name: &str, default: T) -> Twhere
MultiValues: MultiValuesFirstGetter<T>,
fn get_or<T>(&self, name: &str, default: T) -> Twhere
MultiValues: MultiValuesFirstGetter<T>,
Gets a value or
default if the key is missing or conversion fails (same
as crate::Config::get_or).Source§fn get_string(&self, name: &str) -> ConfigResult<String>
fn get_string(&self, name: &str) -> ConfigResult<String>
Gets a string value, applying variable substitution when enabled. Read more
Source§fn get_string_or(&self, name: &str, default: &str) -> String
fn get_string_or(&self, name: &str, default: &str) -> String
Gets a string value with substitution, or
default if lookup or
substitution fails. Read moreSource§fn get_string_list(&self, name: &str) -> ConfigResult<Vec<String>>
fn get_string_list(&self, name: &str) -> ConfigResult<Vec<String>>
Gets all string values for
name, applying substitution to each element
when enabled. Read moreSource§fn get_string_list_or(&self, name: &str, default: &[&str]) -> Vec<String>
fn get_string_list_or(&self, name: &str, default: &[&str]) -> Vec<String>
Gets a string list with substitution, or copies
default if lookup
fails. Read moreSource§fn get_optional_string(&self, name: &str) -> ConfigResult<Option<String>>
fn get_optional_string(&self, name: &str) -> ConfigResult<Option<String>>
Gets an optional string with the same three-way semantics as
crate::Config::get_optional_string. Read moreSource§fn get_optional_string_list(
&self,
name: &str,
) -> ConfigResult<Option<Vec<String>>>
fn get_optional_string_list( &self, name: &str, ) -> ConfigResult<Option<Vec<String>>>
Gets an optional string list with per-element substitution when enabled. Read more
Auto Trait Implementations§
impl<'a> Freeze for ConfigPrefixView<'a>
impl<'a> RefUnwindSafe for ConfigPrefixView<'a>
impl<'a> Send for ConfigPrefixView<'a>
impl<'a> Sync for ConfigPrefixView<'a>
impl<'a> Unpin for ConfigPrefixView<'a>
impl<'a> UnsafeUnpin for ConfigPrefixView<'a>
impl<'a> UnwindSafe for ConfigPrefixView<'a>
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
Mutably borrows from an owned value. Read more