1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-01 18:51:04 +02:00

build: update deps

This commit is contained in:
Jake Stanger 2023-01-28 15:41:52 +00:00
parent 1ed3220733
commit ad97550583
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
4 changed files with 96 additions and 17 deletions

View file

@ -123,6 +123,9 @@ impl Config {
/// and parses it into `Self` based on its extension.
fn load_file(path: &Path) -> Result<Self> {
let file = fs::read(path).wrap_err("Failed to read config file")?;
let str = std::str::from_utf8(&file)?;
let extension = path
.extension()
.unwrap_or_default()
@ -130,10 +133,10 @@ impl Config {
.unwrap_or_default();
match extension {
"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" => libcorn::from_slice(&file).wrap_err("Invalid Corn config"),
"json" => serde_json::from_str(str).wrap_err("Invalid JSON config"),
"toml" => toml::from_str(str).wrap_err("Invalid TOML config"),
"yaml" | "yml" => serde_yaml::from_str(str).wrap_err("Invalid YAML config"),
"corn" => libcorn::from_str(str).wrap_err("Invalid Corn config"),
_ => unreachable!(),
}
}