use crate::error::Result;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HardwareInfo {
pub model: String,
pub p_number: Option<String>,
pub module: Option<String>,
pub soc: Option<String>,
pub cuda_arch: Option<String>,
pub codename: Option<String>,
pub serial_number: Option<String>,
pub l4t: Option<String>,
pub jetpack: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PlatformInfo {
pub machine: String,
pub system: String,
pub distribution: Option<String>,
pub release: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LibraryVersions {
pub cuda: Option<String>,
pub cudnn: Option<String>,
pub tensorrt: Option<String>,
pub other: HashMap<String, String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BoardInfo {
pub platform: PlatformInfo,
pub hardware: HardwareInfo,
pub libraries: LibraryVersions,
}
impl BoardInfo {
pub fn new() -> Result<Self> {
Ok(Self {
platform: PlatformInfo {
machine: String::new(),
system: String::new(),
distribution: None,
release: String::new(),
},
hardware: HardwareInfo {
model: String::new(),
p_number: None,
module: None,
soc: None,
cuda_arch: None,
codename: None,
serial_number: None,
l4t: None,
jetpack: None,
},
libraries: LibraryVersions {
cuda: None,
cudnn: None,
tensorrt: None,
other: HashMap::new(),
},
})
}
}
impl Default for BoardInfo {
fn default() -> Self {
Self::new().unwrap_or_else(|_| Self {
platform: PlatformInfo {
machine: String::new(),
system: String::new(),
distribution: None,
release: String::new(),
},
hardware: HardwareInfo {
model: String::new(),
p_number: None,
module: None,
soc: None,
cuda_arch: None,
codename: None,
serial_number: None,
l4t: None,
jetpack: None,
},
libraries: LibraryVersions {
cuda: None,
cudnn: None,
tensorrt: None,
other: HashMap::new(),
},
})
}
}