summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.rs22
-rw-r--r--src/main.rs5
2 files changed, 27 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs
new file mode 100644
index 0000000..f101456
--- /dev/null
+++ b/src/config.rs
@@ -0,0 +1,22 @@
+use serde::Deserialize;
+use std::fs;
+
+#[derive(Deserialize, Debug)]
+struct Config {
+ title: String,
+ url: String,
+ author: String,
+}
+
+pub fn parse_file(filename: &str) {
+ println!("loaded {} config file", filename);
+ let contents = fs::read_to_string(filename)
+ .expect("something went wrong reading to file");
+
+ let config: Config = toml::from_str(&contents)
+ .expect("failed to parse toml formatting");
+
+ println!("title: {}", config.title);
+ println!("url: {}", config.url);
+ println!("author: {}", config.author);
+}
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..04d0a96
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,5 @@
+mod config;
+
+fn main() {
+ config::parse_file("ahsi.toml");
+}