config.rs 380 B

1234567891011121314151617181920
  1. use serde::Deserialize;
  2. pub fn parse_config(config_str: &str) -> Result<Config, toml::de::Error> {
  3. toml::from_str(config_str)
  4. }
  5. #[derive(Deserialize)]
  6. pub struct Config {
  7. pub default_questions: String,
  8. pub server_config: ServerConfig
  9. }
  10. #[derive(Deserialize)]
  11. pub struct ServerConfig {
  12. pub ip: String,
  13. pub port: Option<u16>,
  14. pub workers: Option<u32>
  15. }