From 94def67e85bdd84c60a731984cfc1fdc8d52f867 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Thu, 16 Sep 2021 14:50:50 -0700 Subject: [PATCH] Start config parsing code --- src/config.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/config.rs diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 00000000..735540f2 --- /dev/null +++ b/src/config.rs @@ -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 { + Ok(Self(Document::from_str(s)?)) + } + + fn buttons(&self) -> Option { + Some(Buttons(self.0.as_table().get("buttons")?.as_table()?)) + } +}