Initial commit: CPU management API
This commit is contained in:
19
src/settings.rs
Normal file
19
src/settings.rs
Normal file
@ -0,0 +1,19 @@
|
||||
use config::Config;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct Settings {
|
||||
pub host: String,
|
||||
pub port: u16,
|
||||
pub database_url: String,
|
||||
}
|
||||
|
||||
impl Settings {
|
||||
pub fn new() -> Result<Self, config::ConfigError> {
|
||||
let settings = Config::builder()
|
||||
.add_source(config::File::with_name("settings"))
|
||||
.build()?;
|
||||
|
||||
settings.try_deserialize()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user