--- /dev/null
+use std::{fmt, fs::File};
+
+use ron::de::from_reader;
+use serde::Deserialize;
+
+use crate::consts;
+
+#[derive(Deserialize, Clone)]
+pub struct Config {
+ pub port: u16,
+ pub smtp_login: String,
+ pub smtp_password: String,
+}
+
+// Avoid to print passwords.
+impl fmt::Debug for Config {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ f.debug_struct("Config")
+ .field("port", &self.port)
+ .field("smtp_login", &self.smtp_login)
+ .field("smtp_password", &"*****")
+ .finish()
+ }
+}
+
+pub fn load() -> Config {
+ let f = File::open(consts::FILE_CONF).unwrap_or_else(|_| panic!("Failed to open configuration file {}", consts::FILE_CONF));
+ match from_reader(f) {
+ Ok(c) => c,
+ Err(e) => panic!("Failed to load config: {}", e)
+ }
+}
\ No newline at end of file