#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Deserialize, Serialize)]
#[repr(transparent)]
pub struct PciDriverName(DriverName);
impl From<DriverName> for PciDriverName
{
#[inline(always)]
fn from(value: DriverName) -> Self
{
Self(value)
}
}
impl<'a> IntoLineFeedTerminatedByteString<'a> for &'a PciDriverName
{
#[inline(always)]
fn into_line_feed_terminated_byte_string(self) -> Cow<'a, [u8]>
{
self.0.into_line_feed_terminated_byte_string()
}
}
impl PciDriverName
{
#[inline(always)]
pub(crate) fn bind(&self, sys_path: &SysPath, pci_device_address: PciDeviceAddress)
{
self.driver_file_path(sys_path, "bind").write_value(pci_device_address).unwrap()
}
#[inline(always)]
pub(crate) fn unbind(&self, sys_path: &SysPath, pci_device_address: PciDeviceAddress)
{
self.driver_file_path(sys_path, "unbind").write_value(pci_device_address).unwrap()
}
#[inline(always)]
fn driver_file_path(&self, sys_path: &SysPath, file_name: &str) -> PathBuf
{
let os_string: OsString = (&self.0).into();
sys_path.pci_driver_folder_path(os_string).append(file_name)
}
}