initial commit

This commit is contained in:
Henrik Friedrichsen
2018-11-11 00:01:00 +01:00
commit 8ddf4498ba
6 changed files with 313 additions and 0 deletions

18
src/config.rs Normal file
View File

@@ -0,0 +1,18 @@
use std::fs::File;
use std::io::prelude::*;
#[derive(Serialize, Deserialize, Debug)]
pub struct Config {
pub username: String,
pub password: String,
pub client_id: String,
}
pub fn load(filename: &str) -> Result<Config, toml::de::Error> {
let mut f = File::open(filename).expect("ncspot configuration file not found");
let mut contents = String::new();
f.read_to_string(&mut contents)
.expect("something went wrong reading the file");
toml::from_str(&contents)
}