use self::util::{read_uevent, write_uevent};
use std::collections::HashMap;
mod block;
mod device;
pub(crate) mod util;
pub use self::{block::*, device::*};
pub(crate) const SYSFS_PATH: &str = "/sys";
pub(crate) const MODULE_PATH: &str = "/lib/modules";
pub enum UEventAction {
Add,
Remove,
Change,
}
pub trait UEvent {
fn write(&self, action: UEventAction, uuid: Option<String>, args: HashMap<String, String>);
fn read(&self) -> HashMap<String, String>;
}
impl<T> UEvent for T
where
T: Device,
{
fn write(&self, action: UEventAction, uuid: Option<String>, args: HashMap<String, String>) {
write_uevent(&self.device_path().join("uevent"), action, uuid, args)
}
fn read(&self) -> HashMap<String, String> {
read_uevent(&self.device_path().join("uevent"))
}
}