1 use std::error::Error;
2 
3 use crate::{map::Map, value::Value};
4 
5 /// Describes a format of configuration source data
6 ///
7 /// Implementations of this trait can be used to convert [`File`](crate::File) sources to configuration data.
8 ///
9 /// There can be various formats, some of them provided by this library, such as JSON, Yaml and other.
10 /// This trait enables users of the library to easily define their own, even proprietary formats without
11 /// the need to alter library sources.
12 ///
13 /// What is more, it is recommended to use this trait with custom [`Source`](crate::Source)s and their async counterparts.
14 pub trait Format {
15     /// Parses provided content into configuration values understood by the library.
16     ///
17     /// It also allows specifying optional URI of the source associated with format instance that can facilitate debugging.
parse( &self, uri: Option<&String>, text: &str, ) -> Result<Map<String, Value>, Box<dyn Error + Send + Sync>>18     fn parse(
19         &self,
20         uri: Option<&String>,
21         text: &str,
22     ) -> Result<Map<String, Value>, Box<dyn Error + Send + Sync>>;
23 }
24