Fix parsing TOML key 'position' and values (#281)

* fix parsing toml key position and values

* Using rename_all instead rename over each enum

* rename struct field directly

---------

Co-authored-by: Ferdinand Schober <ferdinand.schober@fau.de>
This commit is contained in:
Michel Lao
2025-03-21 14:02:38 +01:00
committed by GitHub
parent 5736919f89
commit 15296263b2
2 changed files with 3 additions and 2 deletions

View File

@@ -59,6 +59,7 @@ pub enum IpcError {
pub const DEFAULT_PORT: u16 = 4242;
#[derive(Debug, Default, Eq, Hash, PartialEq, Clone, Copy, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Position {
#[default]
Left,

View File

@@ -61,7 +61,7 @@ struct TomlClient {
host_name: Option<String>,
ips: Option<Vec<IpAddr>>,
port: Option<u16>,
pos: Option<Position>,
position: Option<Position>,
activate_on_startup: Option<bool>,
enter_hook: Option<String>,
}
@@ -262,7 +262,7 @@ impl From<TomlClient> for ConfigClient {
let hostname = toml.hostname;
let ips = HashSet::from_iter(toml.ips.into_iter().flatten());
let port = toml.port.unwrap_or(DEFAULT_PORT);
let pos = toml.pos.unwrap_or_default();
let pos = toml.position.unwrap_or_default();
Self {
ips,
hostname,