It works kinda?
This commit is contained in:
29
src/config.rs
Normal file
29
src/config.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
extern crate serde_derive;
|
||||
extern crate toml;
|
||||
use toml::de::Error;
|
||||
// use serde_derive::Deserialize;
|
||||
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct Config {
|
||||
pub port: i32,
|
||||
pub host: String,
|
||||
pub server: Vec<Server>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct Server {
|
||||
pub url: String,
|
||||
pub dir: String,
|
||||
pub key: String,
|
||||
pub cert: String,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn new(file: &str) -> Config {
|
||||
let fd = std::fs::read_to_string(file).unwrap();
|
||||
let config: Config = toml::from_str(&fd).unwrap();
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user