Skip to main content

ConfigPrefixView

Struct ConfigPrefixView 

Source
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>

Source

pub fn prefix(&self) -> &str

Gets the logical prefix of this view.

§Returns

The normalized prefix string (no leading or trailing dot separators).

Source

pub fn prefix_view(&self, prefix: &str) -> ConfigPrefixView<'a>

Creates a nested prefix view by appending prefix.

§Parameters
  • prefix - Segment to append (. is trimmed); empty keeps the current prefix.
§Returns

A new view with the combined prefix.

Trait Implementations§

Source§

impl<'a> Clone for ConfigPrefixView<'a>

Source§

fn clone(&self) -> ConfigPrefixView<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> ConfigReader for ConfigPrefixView<'a>

Source§

fn is_enable_variable_substitution(&self) -> bool

Returns whether ${...} variable substitution is applied when reading string values. Read more
Source§

fn max_substitution_depth(&self) -> usize

Returns the maximum recursion depth allowed when resolving nested ${...} references. Read more
Source§

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 get_property(&self, name: &str) -> Option<&Property>

Returns a reference to the raw Property for name, if present. Read more
Source§

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 is_empty(&self) -> bool

Returns true when Self::len is zero.
Source§

fn keys(&self) -> Vec<String>

All keys visible to this reader (relative keys for a prefix view).
Source§

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>,

Reads the first stored value for name and converts it to T. Read more
Source§

fn get_list<T>(&self, name: &str) -> ConfigResult<Vec<T>>
where MultiValues: MultiValuesGetter<T>,

Reads all stored values for name and converts each element to T. Read more
Source§

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 more
Source§

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 more
Source§

fn contains_prefix(&self, prefix: &str) -> bool

Returns whether any key visible to this reader starts with prefix. Read more
Source§

fn iter_prefix<'b>( &'b self, prefix: &'b str, ) -> Box<dyn Iterator<Item = (&'b str, &'b Property)> + 'b>

Iterates (key, property) pairs for keys that start with prefix. Read more
Source§

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

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>

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>

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>

Creates a read-only prefix view; relative keys resolve under prefix. Read more
Source§

fn resolve_key(&self, name: &str) -> String

Resolves name into the canonical key path against the root crate::Config. Read more
Source§

fn get_or<T>(&self, name: &str, default: T) -> T
where 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>

Gets a string value, applying variable substitution when enabled. Read more
Source§

fn get_string_or(&self, name: &str, default: &str) -> String

Gets a string value with substitution, or default if lookup or substitution fails. Read more
Source§

fn get_string_list(&self, name: &str) -> ConfigResult<Vec<String>>

Gets all string values for name, applying substitution to each element when enabled. Read more
Source§

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 more
Source§

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 more
Source§

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
Source§

impl<'a> Debug for ConfigPrefixView<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.