use iron::typemap::Key;
use std::fs::File;
use std::io::prelude::*;
use toml;
#[derive(Clone, Debug, Deserialize)]
pub struct Config {
pub ldap: Option<LDAP>,
pub livy_client: LivyClient,
pub http: HTTP,
}
impl Config {
pub fn from(conf_path: &str) -> Config {
let mut f = File::open(conf_path).unwrap();
let mut contents = String::new();
f.read_to_string(&mut contents).unwrap();
toml::from_str(contents.as_str()).unwrap()
}
}
impl Key for Config {
type Value = Self;
}
#[derive(Clone, Debug, Deserialize)]
pub struct LDAP {
pub url: String,
pub user_dn: String,
pub admin_group_dn: String,
}
#[derive(Clone, Debug, Deserialize)]
pub struct LivyClient {
pub url: String,
pub gssnegotiate: Option<bool>,
pub username: Option<String>,
}
#[derive(Clone, Debug, Deserialize)]
pub struct HTTP {
pub addr: String,
pub num_threads: usize,
}