Trait config::Format

source ·
pub trait Format {
    // Required method
    fn parse(
        &self,
        uri: Option<&String>,
        text: &str
    ) -> Result<Map<String, Value>, Box<dyn Error + Send + Sync>>;
}
Expand description

Describes a format of configuration source data

Implementations of this trait can be used to convert File sources to configuration data.

There can be various formats, some of them provided by this library, such as JSON, Yaml and other. This trait enables users of the library to easily define their own, even proprietary formats without the need to alter library sources.

What is more, it is recommended to use this trait with custom Sources and their async counterparts.

Required Methods§

source

fn parse( &self, uri: Option<&String>, text: &str ) -> Result<Map<String, Value>, Box<dyn Error + Send + Sync>>

Parses provided content into configuration values understood by the library.

It also allows specifying optional URI of the source associated with format instance that can facilitate debugging.

Implementors§