diff --git a/crates/omnix-common/src/config.rs b/crates/omnix-common/src/config.rs index da6959c1..1901c77b 100644 --- a/crates/omnix-common/src/config.rs +++ b/crates/omnix-common/src/config.rs @@ -8,26 +8,6 @@ use nix_rs::{ }; use serde::{de::DeserializeOwned, Deserialize}; -/// Represents the whole configuration for `omnix` parsed from JSON -#[derive(Debug, Default, Deserialize)] -pub struct Config(BTreeMap>); - -impl Config { - /// Get all the configs of type `T` for a given sub-config - /// Returns None if sub_config doesn't exist, or Some(Err) if deserialization fails - pub fn get(&self, sub_config: &str) -> Option, serde_json::Error>> - where - T: DeserializeOwned, - { - self.0.get(sub_config).map(|config| { - config - .iter() - .map(|(k, v)| serde_json::from_value(v.clone()).map(|value| (k.clone(), value))) - .collect() - }) - } -} - /// [Config] with additional metadata about the flake URL and reference. /// /// `reference` here is the part of the flake URL after `#` @@ -92,6 +72,26 @@ impl OmConfig { } } +/// Represents the whole configuration for `omnix` parsed from JSON +#[derive(Debug, Default, Deserialize)] +pub struct Config(BTreeMap>); + +impl Config { + /// Get all the configs of type `T` for a given sub-config + /// Returns None if sub_config doesn't exist, or Some(Err) if deserialization fails + pub fn get(&self, sub_config: &str) -> Option, serde_json::Error>> + where + T: DeserializeOwned, + { + self.0.get(sub_config).map(|config| { + config + .iter() + .map(|(k, v)| serde_json::from_value(v.clone()).map(|value| (k.clone(), value))) + .collect() + }) + } +} + /// Error type for OmConfig #[derive(thiserror::Error, Debug)] pub enum OmConfigError {