Start config parsing code
This commit is contained in:
parent
ec6a0ff366
commit
94def67e85
1 changed files with 16 additions and 0 deletions
16
src/config.rs
Normal file
16
src/config.rs
Normal 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()?))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue