1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-01 10:41:03 +02:00

refactor: use latest libcorn with serde support

This should speed Corn config loading up a bit :)
This commit is contained in:
Jake Stanger 2022-11-28 22:23:11 +00:00
parent cf87bb4e8d
commit 0fb5fa8c2a
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
3 changed files with 153 additions and 141 deletions

View file

@ -175,14 +175,7 @@ impl Config {
"json" => serde_json::from_slice(&file).wrap_err("Invalid JSON config"),
"toml" => toml::from_slice(&file).wrap_err("Invalid TOML config"),
"yaml" | "yml" => serde_yaml::from_slice(&file).wrap_err("Invalid YAML config"),
"corn" => {
// corn doesn't support deserialization yet
// so serialize the interpreted result then deserialize that
let file =
String::from_utf8(file).wrap_err("Config file contains invalid UTF-8")?;
let config = libcorn::parse(&file).wrap_err("Invalid corn config")?.value;
Ok(serde_json::from_str(&serde_json::to_string(&config)?)?)
}
"corn" => libcorn::from_slice(&file).wrap_err("Invalid Corn config"),
_ => unreachable!(),
}
}