Trait Configuration

Source
pub trait Configuration {
    // Required methods
    fn get(&self, key: &str) -> Option<Value>;
    fn section(&self, key: &str) -> Box<dyn ConfigurationSection>;
    fn children(&self) -> Vec<Box<dyn ConfigurationSection>>;
    fn reload_token(&self) -> Box<dyn ChangeToken>;
    fn iter(
        &self,
        path: Option<ConfigurationPath>,
    ) -> Box<dyn Iterator<Item = (String, Value)>>;

    // Provided method
    fn as_section(&self) -> Option<&dyn ConfigurationSection> { ... }
}
Expand description

Defines the behavior of a configuration.

Required Methods§

Source

fn get(&self, key: &str) -> Option<Value>

Gets the configuration value.

§Arguments
  • key - The configuration key
Source

fn section(&self, key: &str) -> Box<dyn ConfigurationSection>

Gets a ConfigurationSection with the specified key.

Source

fn children(&self) -> Vec<Box<dyn ConfigurationSection>>

Gets the sequence of ConfigurationSection children.

Source

fn reload_token(&self) -> Box<dyn ChangeToken>

Returns a ChangeToken that can be used to observe when this configuration is reloaded.

Source

fn iter( &self, path: Option<ConfigurationPath>, ) -> Box<dyn Iterator<Item = (String, Value)>>

Gets an iterator of the key/value pairs within the Configuration.

§Arguments

Provided Methods§

Source

fn as_section(&self) -> Option<&dyn ConfigurationSection>

Attempts to convert the Configuration as a ConfigurationSection.

Trait Implementations§

Source§

impl<'a> AsRef<dyn Configuration + 'a> for DefaultConfigurationRoot

Source§

fn as_ref(&self) -> &(dyn Configuration + 'a)

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'a> AsRef<dyn Configuration + 'a> for DefaultConfigurationSection

Source§

fn as_ref(&self) -> &(dyn Configuration + 'a)

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'a> Borrow<dyn Configuration + 'a> for DefaultConfigurationRoot

Source§

fn borrow(&self) -> &(dyn Configuration + 'a)

Immutably borrows from an owned value. Read more
Source§

impl<'a> Borrow<dyn Configuration + 'a> for DefaultConfigurationSection

Source§

fn borrow(&self) -> &(dyn Configuration + 'a)

Immutably borrows from an owned value. Read more
Source§

impl ConfigurationBinder for dyn Configuration + '_

Source§

fn reify<T: DeserializeOwned>(&self) -> T

Creates and returns a structure bound to the configuration.
Source§

fn bind<T: DeserializeOwned>(&self, instance: &mut T)

Binds the configuration to the specified instance. Read more
Source§

fn bind_at<T: DeserializeOwned>(&self, key: impl AsRef<str>, instance: &mut T)

Binds the specified configuration section to the provided instance. Read more
Source§

fn get_value<T: FromStr>( &self, key: impl AsRef<str>, ) -> Result<Option<T>, T::Err>

Gets a typed value from the configuration. Read more
Source§

fn get_value_or_default<T: FromStr + Default>( &self, key: impl AsRef<str>, ) -> Result<T, T::Err>

Gets an optional, typed value from the configuration. Read more

Implementors§