lib: print config at startup

This commit is contained in:
Matt Bilker
2025-11-13 15:57:57 +00:00
parent 3bb53fdfa5
commit edd1827cf4
3 changed files with 9 additions and 4 deletions

View File

@@ -20,7 +20,7 @@ impl Defaults {
}
}
#[derive(Deserialize)]
#[derive(Debug, Deserialize)]
pub struct Config {
#[serde(default = "Defaults::unlock")]
pub unlock: bool,
@@ -30,7 +30,7 @@ pub struct Config {
pub pci_info_map: Option<HashMap<U32, PciInfoMapEntry>>,
}
#[derive(Deserialize)]
#[derive(Debug, Deserialize)]
pub struct PciInfoMapEntry {
pub device_id: u16,
pub sub_system_id: u16,

View File

@@ -76,7 +76,11 @@ static LAST_MDEV_UUID: Mutex<Option<Uuid>> = parking_lot::const_mutex(None);
static CONFIG: Config = {
match fs::read_to_string(DEFAULT_CONFIG_PATH) {
Ok(config) => match toml::from_str::<Config>(&config) {
Ok(config) => config,
Ok(config) => {
println!("{:?}", config);
config
}
Err(e) => {
eprintln!("Failed to decode config: {}", e);

View File

@@ -33,7 +33,8 @@ impl<'de> Deserialize<'de> for U32 {
match u32::from_str_radix(v, radix) {
Ok(n) => Ok(Self(n)),
Err(e) => Err(D::Error::custom(format!(
"Failed to parse string as base-{radix} integer: {e}"
"Failed to parse string as base-{} integer: {}",
radix, e
))),
}
}