blob: 8dc8a6ff02abed8ae617fc8692c24825d1d3c3e3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
use serde::Deserialize;
use std::fs;
#[derive(Deserialize, Debug)]
pub struct Config {
pub title: String,
pub url: String,
pub 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);
}
|