Trait sysfs_class::SysClass
source · pub trait SysClass: Sized {
fn class() -> &'static str;
unsafe fn from_path_unchecked(path: PathBuf) -> Self;
fn path(&self) -> &Path;
fn dir() -> PathBuf { ... }
fn from_path(path: &Path) -> Result<Self> { ... }
fn all() -> Result<Vec<Self>> { ... }
fn new(id: &str) -> Result<Self> { ... }
fn id(&self) -> &str { ... }
fn read_file<P: AsRef<Path>>(&self, name: P) -> Result<String> { ... }
fn parse_file<F: FromStr, P: AsRef<Path>>(&self, name: P) -> Result<F>
where
F::Err: Display,
{ ... }
fn trim_file<P: AsRef<Path>>(&self, name: P) -> Result<String> { ... }
fn write_file<P: AsRef<Path>, S: AsRef<[u8]>>(
&self,
name: P,
data: S
) -> Result<()> { ... }
}
Required Methods
sourcefn class() -> &'static str
fn class() -> &'static str
Return the class of the sys object, the name of a folder in /sys/class
sourceunsafe fn from_path_unchecked(path: PathBuf) -> Self
unsafe fn from_path_unchecked(path: PathBuf) -> Self
Create a sys object from an absolute path without checking path for validity
Provided Methods
sourcefn dir() -> PathBuf
fn dir() -> PathBuf
Return the path to the sys objects, the full path of a folder in /sys/class
sourcefn from_path(path: &Path) -> Result<Self>
fn from_path(path: &Path) -> Result<Self>
Create a sys object from a path, checking it for validity
sourcefn read_file<P: AsRef<Path>>(&self, name: P) -> Result<String>
fn read_file<P: AsRef<Path>>(&self, name: P) -> Result<String>
Read a file underneath the sys object
sourcefn parse_file<F: FromStr, P: AsRef<Path>>(&self, name: P) -> Result<F>where
F::Err: Display,
fn parse_file<F: FromStr, P: AsRef<Path>>(&self, name: P) -> Result<F>where
F::Err: Display,
Parse a number from a file underneath the sys object