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()?)) } }