add yaml config support

This commit is contained in:
Toshit Chawda 2024-07-22 13:54:41 -07:00
parent 29f05a2ddd
commit 6bb5be5179
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
3 changed files with 24 additions and 0 deletions

20
Cargo.lock generated
View file

@ -567,6 +567,7 @@ dependencies = [
"regex", "regex",
"serde", "serde",
"serde_json", "serde_json",
"serde_yaml",
"tokio", "tokio",
"tokio-util", "tokio-util",
"toml", "toml",
@ -1538,6 +1539,19 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "serde_yaml"
version = "0.9.34+deprecated"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47"
dependencies = [
"indexmap 2.2.6",
"itoa",
"ryu",
"serde",
"unsafe-libyaml",
]
[[package]] [[package]]
name = "sha1" name = "sha1"
version = "0.10.6" version = "0.10.6"
@ -1918,6 +1932,12 @@ version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unsafe-libyaml"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
[[package]] [[package]]
name = "untrusted" name = "untrusted"
version = "0.9.0" version = "0.9.0"

View file

@ -19,6 +19,7 @@ log = { version = "0.4.22", features = ["serde", "std"] }
regex = "1.10.5" regex = "1.10.5"
serde = { version = "1.0.204", features = ["derive"] } serde = { version = "1.0.204", features = ["derive"] }
serde_json = "1.0.120" serde_json = "1.0.120"
serde_yaml = "0.9.34"
tokio = { version = "1.38.1", features = ["full"] } tokio = { version = "1.38.1", features = ["full"] }
tokio-util = { version = "0.7.11", features = ["compat", "io-util", "net"] } tokio-util = { version = "0.7.11", features = ["compat", "io-util", "net"] }
toml = "0.8.15" toml = "0.8.15"

View file

@ -242,6 +242,7 @@ impl Config {
Ok(match CLI.format { Ok(match CLI.format {
ConfigFormat::Toml => toml::to_string_pretty(self)?, ConfigFormat::Toml => toml::to_string_pretty(self)?,
ConfigFormat::Json => serde_json::to_string_pretty(self)?, ConfigFormat::Json => serde_json::to_string_pretty(self)?,
ConfigFormat::Yaml => serde_yaml::to_string(self)?,
}) })
} }
@ -249,6 +250,7 @@ impl Config {
Ok(match CLI.format { Ok(match CLI.format {
ConfigFormat::Toml => toml::from_str(&string)?, ConfigFormat::Toml => toml::from_str(&string)?,
ConfigFormat::Json => serde_json::from_str(&string)?, ConfigFormat::Json => serde_json::from_str(&string)?,
ConfigFormat::Yaml => serde_yaml::from_str(&string)?,
}) })
} }
} }
@ -258,6 +260,7 @@ pub enum ConfigFormat {
#[default] #[default]
Toml, Toml,
Json, Json,
Yaml,
} }
/// Server implementation of the Wisp protocol in Rust, made for epoxy. /// Server implementation of the Wisp protocol in Rust, made for epoxy.