impl SystemDMI {
pub(crate) fn get() -> Result<Self> {
- let system_files = vec![
+ let system_files = [
"product_serial",
"product_sku",
"product_uuid",
"product_name",
];
- let baseboard_files = vec!["board_asset_tag", "board_serial", "board_name"];
- let chassis_files = vec!["chassis_serial", "chassis_sku", "chassis_asset_tag"];
+ let baseboard_files = ["board_asset_tag", "board_serial", "board_name"];
+ let chassis_files = ["chassis_serial", "chassis_sku", "chassis_asset_tag"];
Ok(Self {
- system: Self::get_dmi_infos(system_files)?,
- baseboard: Self::get_dmi_infos(baseboard_files)?,
- chassis: Self::get_dmi_infos(chassis_files)?,
+ system: Self::get_dmi_infos(&system_files)?,
+ baseboard: Self::get_dmi_infos(&baseboard_files)?,
+ chassis: Self::get_dmi_infos(&chassis_files)?,
})
}
- fn get_dmi_infos(files: Vec<&str>) -> Result<HashMap<String, String>> {
+
+ fn get_dmi_infos(files: &[&str]) -> Result<HashMap<String, String>> {
let mut res: HashMap<String, String> = HashMap::new();
for file in files {
.arg("-j")
.arg("link")
.output()?;
- let parsed_links: Vec<IpLinksUdevInfo> =
- serde_json::from_str(String::from_utf8(ip_output.stdout)?.as_str())?;
+ let parsed_links: Vec<IpLinksUdevInfo> = serde_json::from_slice(&ip_output.stdout)?;
let mut links: Vec<String> = Vec::new();
for link in parsed_links {
};
}
- if fingerprint.is_some() {
- let fp = fingerprint.clone();
- fs::write("/tmp/cert_fingerprint", fp.unwrap()).ok();
+ if let Some(fingerprint) = &fingerprint {
+ let _ = fs::write("/tmp/cert_fingerprint", fingerprint);
}
info!("Gathering system information.");
/// * `runinfo` - `RuntimeInfo` instance of currently running system
/// * `disks` - List of disks designated as bootdisk targets.
pub fn check_disks_4kn_legacy_boot(boot_type: BootType, disks: &[Disk]) -> Result<(), &str> {
- let is_blocksize_4096 = |disk: &Disk| disk.block_size.map(|s| s == 4096).unwrap_or(false);
-
- if boot_type == BootType::Bios && disks.iter().any(is_blocksize_4096) {
+ if boot_type == BootType::Bios && disks.iter().any(|disk| disk.block_size == Some(4096)) {
return Err("Booting from 4Kn drive in legacy BIOS mode is not supported.");
}
impl fmt::Display for ProxmoxProduct {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- match self {
- Self::PVE => write!(f, "pve"),
- Self::PMG => write!(f, "pmg"),
- Self::PBS => write!(f, "pbs"),
- }
+ f.write_str(match self {
+ Self::PVE => "pve",
+ Self::PMG => "pmg",
+ Self::PBS => "pbs",
+ })
}
}