Nicolas Winkler 4 éve
szülő
commit
8e0ccca679
2 módosított fájl, 25 hozzáadás és 0 törlés
  1. 5 0
      config.toml
  2. 20 0
      src/config.rs

+ 5 - 0
config.toml

@@ -0,0 +1,5 @@
+default_questions = "questions.txt"
+
+[server_config]
+ip = "127.0.0.1"
+port = 8000

+ 20 - 0
src/config.rs

@@ -0,0 +1,20 @@
+use serde::Deserialize;
+
+pub fn parse_config(config_str: &str) -> Result<Config, toml::de::Error> {
+    toml::from_str(config_str)
+}
+
+#[derive(Deserialize)]
+pub struct Config {
+    pub default_questions: String,
+    pub server_config: ServerConfig
+}
+
+#[derive(Deserialize)]
+pub struct ServerConfig {
+    pub ip: String,
+    pub port: Option<u16>,
+    pub workers: Option<u32>
+}
+
+