use crate::Error;
use crate::sys::utils::get_kenv_var;
const FAMILY: &[u8] = b"smbios.system.family\0";
const NAME: &[u8] = b"smbios.system.product\0";
const SERIAL_NUMBER: &[u8] = b"smbios.system.serial\0";
const SKU: &[u8] = b"smbios.system.sku\0";
const UUID: &[u8] = b"smbios.system.uuid\0";
const VERSION: &[u8] = b"smbios.system.version\0";
const VENDOR: &[u8] = b"smbios.system.maker\0";
pub(crate) struct ProductInner;
impl ProductInner {
fn required(key: &[u8], message: &'static str) -> Result<String, Error> {
get_kenv_var(key).ok_or_else(|| Error::Other(message.into()))
}
pub(crate) fn family() -> Result<String, Error> {
Self::required(FAMILY, "failed to retrieve product family")
}
pub(crate) fn name() -> Result<String, Error> {
Self::required(NAME, "failed to retrieve product name")
}
pub(crate) fn serial_number() -> Result<String, Error> {
Self::required(SERIAL_NUMBER, "failed to retrieve product serial number")
}
pub(crate) fn stock_keeping_unit() -> Result<String, Error> {
Self::required(SKU, "failed to retrieve product stock keeping unit")
}
pub(crate) fn uuid() -> Result<String, Error> {
Self::required(UUID, "failed to retrieve product uuid")
}
pub(crate) fn version() -> Result<String, Error> {
Self::required(VERSION, "failed to retrieve product version")
}
pub(crate) fn vendor_name() -> Result<String, Error> {
Self::required(VENDOR, "failed to retrieve product vendor name")
}
}