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§
Sourcefn section(&self, key: &str) -> Box<dyn ConfigurationSection>
fn section(&self, key: &str) -> Box<dyn ConfigurationSection>
Gets a ConfigurationSection
with the specified key.
Sourcefn children(&self) -> Vec<Box<dyn ConfigurationSection>>
fn children(&self) -> Vec<Box<dyn ConfigurationSection>>
Gets the sequence of ConfigurationSection
children.
Sourcefn reload_token(&self) -> Box<dyn ChangeToken>
fn reload_token(&self) -> Box<dyn ChangeToken>
Returns a ChangeToken
that can be used to observe when this configuration is reloaded.
Sourcefn iter(
&self,
path: Option<ConfigurationPath>,
) -> Box<dyn Iterator<Item = (String, Value)>>
fn iter( &self, path: Option<ConfigurationPath>, ) -> Box<dyn Iterator<Item = (String, Value)>>
Gets an iterator of the key/value pairs within the Configuration
.
§Arguments
path
- The type ofConfigurationPath
used when iterating
Provided Methods§
Sourcefn as_section(&self) -> Option<&dyn ConfigurationSection>
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
impl<'a> AsRef<dyn Configuration + 'a> for DefaultConfigurationRoot
Source§fn as_ref(&self) -> &(dyn Configuration + 'a)
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
impl<'a> AsRef<dyn Configuration + 'a> for DefaultConfigurationSection
Source§fn as_ref(&self) -> &(dyn Configuration + 'a)
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
impl<'a> Borrow<dyn Configuration + 'a> for DefaultConfigurationRoot
Source§fn borrow(&self) -> &(dyn Configuration + 'a)
fn borrow(&self) -> &(dyn Configuration + 'a)
Immutably borrows from an owned value. Read more
Source§impl<'a> Borrow<dyn Configuration + 'a> for DefaultConfigurationSection
impl<'a> Borrow<dyn Configuration + 'a> for DefaultConfigurationSection
Source§fn borrow(&self) -> &(dyn Configuration + 'a)
fn borrow(&self) -> &(dyn Configuration + 'a)
Immutably borrows from an owned value. Read more
Source§impl ConfigurationBinder for dyn Configuration + '_
impl ConfigurationBinder for dyn Configuration + '_
Source§fn reify<T: DeserializeOwned>(&self) -> T
fn reify<T: DeserializeOwned>(&self) -> T
Creates and returns a structure bound to the configuration.
Source§fn bind<T: DeserializeOwned>(&self, instance: &mut T)
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)
fn bind_at<T: DeserializeOwned>(&self, key: impl AsRef<str>, instance: &mut T)
Binds the specified configuration section to the provided instance. Read more