decent_toml_rs_alternative/
lib.rs1
2mod tokens;
3mod parser;
4mod value;
5mod printer;
6mod from;
7mod to;
8
9#[cfg(feature="derive")]
10pub use decent_serde_toml_derive_alternative::{FromToml, ToToml};
11
12use std::collections::HashMap;
13
14pub use parser::parse_toml_lines;
15pub use value::{TomlValue, TomlError, toml_value_from_lines, toml_value_from_parser_value};
16pub use printer::print;
17pub use from::FromToml;
18pub use to::ToToml;
19
20pub fn parse_toml(input: &str) -> Result<HashMap<String, TomlValue>, TomlError> {
21 let lines = parse_toml_lines(input)?;
22 let value = toml_value_from_lines(lines)?;
23 Ok(value)
24}
25
26pub fn to_toml_file_content(value: TomlValue) -> String {
27 if let TomlValue::Table(table) = value {
28 print(&table)
29 } else {
30 let mut map = HashMap::new();
31 map.insert("value".to_string(), value);
32 print(&map)
33 }
34}