Skip to main content

Configuration

Trait Configuration 

Source
pub trait Configuration:
    Sized
    + Send
    + Sync
    + Clone {
    type Section: Configuration;
    type Sections: IntoIterator<Item = Self::Section>;

    // Required methods
    fn get<K: Into<ConfigKey>>(&self, key: K) -> Option<&str>;
    fn section<K: Into<ConfigKey>>(&self, key: K) -> Self::Section;
    fn sections(&self) -> Self::Sections;
    fn key(&self) -> &ConfigKey;
    fn path(&self) -> &ConfigKey;
    fn value(&self) -> Option<&str>;
}
Expand description

Configuration trait. Configuration is thread safe, and cloneable. Clones should be cheap (default config object consits of cloning an Arc and 3 String instances).

Required Associated Types§

Source

type Section: Configuration

Type used for configuration sections.

Source

type Sections: IntoIterator<Item = Self::Section>

Iterator type used to get child sections.

Required Methods§

Source

fn get<K: Into<ConfigKey>>(&self, key: K) -> Option<&str>

Get a value from the configuration, if it exists.

Source

fn section<K: Into<ConfigKey>>(&self, key: K) -> Self::Section

Get a sub-section from the configuration. This always returns a section, even if it is empty.

Source

fn sections(&self) -> Self::Sections

Get all child sections of this configuration, as an iterator.

Source

fn key(&self) -> &ConfigKey

Get the current section key.

Source

fn path(&self) -> &ConfigKey

Get the current section path.

Source

fn value(&self) -> Option<&str>

Get the current section value (if any).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§