aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
blob: 13ffa61a23ffbe06ab362ffd3bd09f23514f5e42 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use serde_derive::{Serialize, Deserialize};

#[derive(Debug, Serialize, Deserialize)]
pub struct Config {
	pub worldsmaster_greeting: String,
}
impl Default for Config {
	fn default() -> Self {
		Config {
			worldsmaster_greeting: "Welcome to Whirlsplash!".to_string(),
		}
	}
}

pub fn get_config() -> Result<Config, confy::ConfyError> {
	let config: Config = confy::load_path("./whirl.toml").unwrap();

	Ok(config)
}

pub fn store_config(config: Config) -> Result<(), confy::ConfyError> {
	confy::store_path("./whirl.toml", config)
}