pub fn parse_value<T>(dir: &Path, file: &str) -> Result<T, std::io::Error>
where
    T: FromStr,
{
    let path = dir.join(file);
    let s = fs::read_to_string(&path)?;
    let s = s.trim();

    match s.parse() {
        Ok(v) => Ok(v),
        Err(_) => Err(std::io::Error::new(
            ErrorKind::InvalidData,
            format!(
                "Failed to parse {}: {}",
                path.as_path().to_str().unwrap(),
                s
            ),
        )),
    }
}
/// Read and parse value from a sysfs file
Read and parse value from a sysfs file
Read and parse value from a sysfs file
pub fn parse_value<T>(dir: &Path, file: &str) -> Result<T, std::io::Error>
where
    T: FromStr,
{
    let path = dir.join(file);
    let s = fs::read_to_string(&path)?;
    let s = s.trim();
    match s.parse() {
        Ok(v) => Ok(v),
        Err(_) => Err(std::io::Error::new(
            ErrorKind::InvalidData,
            format!(
                "Failed to parse {}: {}",
                path.as_path().to_str().unwrap(),
                s
            ),
        )),
    }
}
pub fn parse_value < T > ( dir : & Path , file : & str ) -> Result < T , std :: io :: Error > where T : FromStr , { let path = dir . join ( file ) ; let s = fs :: read_to_string ( & path ) ? ; let s = s . trim ( ) ; match s . parse ( ) { Ok ( v ) => Ok ( v ) , Err ( _ ) => Err ( std :: io :: Error :: new ( ErrorKind :: InvalidData , format ! ( " " path as_path ( ) to_str ( ) unwrap ( ) s ) , ) ) , } }
Read and parse value from a sysfs file
Read and parse value from a sysfs file
dir
&Path
file
&str
dir
&Path
file
&str