1
Fork 0
mirror of https://github.com/RGBCube/superfreq synced 2025-07-27 17:07:44 +00:00

config: fix schema, toml does not have top level lists

This commit is contained in:
RGBCube 2025-05-19 21:32:08 +03:00
parent 0d3a88be03
commit c073b640dc
Signed by: RGBCube
SSH key fingerprint: SHA256:CzqbPcfwt+GxFYNnFVCqoN5Itn4YFrshg1TrnACpA5M

View file

@ -111,7 +111,9 @@ pub struct DaemonConfigLayer {
#[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq, Eq)] #[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq, Eq)]
#[serde(transparent, default, rename_all = "kebab-case")] #[serde(transparent, default, rename_all = "kebab-case")]
pub struct DaemonConfig(pub Vec<DaemonConfigLayer>); pub struct DaemonConfig {
config: Vec<DaemonConfigLayer>,
}
impl DaemonConfig { impl DaemonConfig {
pub fn load_from(path: &Path) -> anyhow::Result<Self> { pub fn load_from(path: &Path) -> anyhow::Result<Self> {
@ -122,9 +124,9 @@ impl DaemonConfig {
let config: Self = toml::from_str(&contents).context("failed to parse config file")?; let config: Self = toml::from_str(&contents).context("failed to parse config file")?;
{ {
let mut priorities = Vec::with_capacity(config.0.len()); let mut priorities = Vec::with_capacity(config.config.len());
for layer in &config.0 { for layer in &config.config {
if priorities.contains(&layer.priority) { if priorities.contains(&layer.priority) {
bail!("each config layer must have a different priority") bail!("each config layer must have a different priority")
} }