Start config parsing code

This commit is contained in:
Ian Douglas Scott 2021-09-16 14:50:50 -07:00
parent ec6a0ff366
commit 94def67e85

16
src/config.rs Normal file
View file

@ -0,0 +1,16 @@
use std::str::FromStr;
use toml_edit::{Document, Table, Array, TomlError};
struct Buttons<'a>(&'a Table);
struct Config(Document);
impl Config {
fn new(s: &str) -> Result<Self, TomlError> {
Ok(Self(Document::from_str(s)?))
}
fn buttons(&self) -> Option<Buttons> {
Some(Buttons(self.0.as_table().get("buttons")?.as_table()?))
}
}