💥 Break relay config again

main
_ 2020-11-30 15:52:15 +00:00
parent 14df0bdf92
commit e59bb5b7bc
1 changed files with 3 additions and 3 deletions

View File

@ -14,11 +14,11 @@ use crate::errors::ConfigError;
// set up the HTTP server // set up the HTTP server
pub mod file { pub mod file {
use std::collections::HashMap;
use serde::Deserialize; use serde::Deserialize;
#[derive (Deserialize)] #[derive (Deserialize)]
pub struct Server { pub struct Server {
pub name: String,
pub tripcode: String, pub tripcode: String,
pub display_name: Option <String>, pub display_name: Option <String>,
} }
@ -26,7 +26,7 @@ pub mod file {
#[derive (Deserialize)] #[derive (Deserialize)]
pub struct Config { pub struct Config {
pub port: Option <u16>, pub port: Option <u16>,
pub servers: HashMap <String, Server>, pub servers: Vec <Server>,
} }
} }
@ -62,7 +62,7 @@ impl TryFrom <file::Config> for Config {
fn try_from (f: file::Config) -> Result <Self, Self::Error> { fn try_from (f: file::Config) -> Result <Self, Self::Error> {
let servers = f.servers.into_iter () let servers = f.servers.into_iter ()
.map (|(k, v)| Ok::<_, ConfigError> ((k, v.try_into ()?))); .map (|server| Ok::<_, ConfigError> ((server.name.clone (), server.try_into ()?)));
let servers = itertools::process_results (servers, |i| HashMap::from_iter (i))?; let servers = itertools::process_results (servers, |i| HashMap::from_iter (i))?;