A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: f074e4f4cf156e0d0e8f8f9eebd260ca36a18d69 (1241 bytes)[doc][blame][raw]
1
use std::fs;2
use serde::{Deserialize};4
#[derive(Debug, Clone, Deserialize)]5
pub struct Server {6
pub hostname: String,7
pub port: i32,8
}10
impl ToString for Server {11
fn to_string(&self) -> String {12
format!(13
"{}:{}",14
self.hostname,15
self.port,16
)17
}18
}20
#[derive(Debug, Clone, Deserialize)]21
pub struct Database {22
pub hostname: String,23
pub port: i32,24
pub username: String,25
pub password: String,26
pub database: String,27
}29
impl ToString for Database {30
fn to_string(&self) -> String {31
format!(32
"postgressql://{}:{}@{}:{}/{}?sslmode=disable",33
self.username,34
self.password,35
self.hostname,36
self.port,37
self.database,38
)39
}40
}42
#[derive(Debug, Clone, Deserialize)]43
pub struct Options {44
pub origin: String,45
pub api_url: String,46
}48
#[derive(Debug, Clone, Deserialize)]49
pub struct Config {50
pub server: Server,51
pub database: Database,52
pub options: Options,53
}55
impl Config {56
pub fn from_file(path: &str) -> Result<Self, ron::Error> {57
let raw = fs::read_to_string(path).expect("Unable to locate config.ron file!");58
ron::from_str(&raw)59
}60
}