initial commit
This commit is contained in:
18
src/config.rs
Normal file
18
src/config.rs
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user