refractor into smaller modules
This commit is contained in:
22
src/config.rs
Normal file
22
src/config.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
use std::error::Error;
|
||||
use std::fs;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct Config {
|
||||
pub listen_addr: String,
|
||||
pub server_addr: String,
|
||||
pub motd_server_addr: String,
|
||||
pub rcon_addr: String,
|
||||
pub rcon_password: String,
|
||||
pub idle_timeout_secs: u64,
|
||||
pub polling_interval_millis: u64,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn load(path: &str) -> Result<Self, Box<dyn Error>> {
|
||||
let content = fs::read_to_string(path)?;
|
||||
let config: Config = toml::from_str(&content)?;
|
||||
Ok(config)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user