1use std::collections::BTreeMap;
2
3pub mod parser;
4
5use self::parser::{conf, custom_conf};
6
7pub type Attribute = (String, String);
8pub type Section = (String, BTreeMap<String, String>);
9pub type Conf = BTreeMap<String, BTreeMap<String, String>>;
10
11#[derive(Debug, PartialEq, Eq)]
12pub enum AttributeOrNote {
13 Attribute((String, String)),
14 AttributeWithNote {
15 attribute: (String, String),
16 note: String,
17 },
18 Note(String),
19}
20
21pub fn from_str(str: &str) -> Result<Conf, nom::Err<nom::error::Error<&str>>> {
22 Ok(conf(str)?.1)
23}
24
25pub fn from_str_custom<'a: 'b, 'b: 'c, 'c>(
26 note_starting: &'a str,
27) -> impl FnMut(&'b str) -> Result<Conf, nom::Err<nom::error::Error<&'b str>>> + 'c {
28 move |str: &'b str| Ok(custom_conf(note_starting)(str)?.1)
29}