pub fn generate_cpu_cores() -> Result<Vec<CPUCore>, String> {
        let cpuinfo = CpuInfo::new().unwrap();
        let mut cores = vec![];
        for id in 0..(cpuinfo.num_cores() - 1) {
            let mut info = HashMap::new();
            for (k, v) in cpuinfo.get_info(id).unwrap().iter() {
                info.insert(String::from(*k), String::from(*v));
            }
            cores.push(CPUCore::new(id as u16, info));
        }
        Ok(cores)
    }
/// Parses /proc/cpuinfo and creates instances of CPUCore.
///
///# Examples
///
/// ```
/// use scaphandre::sensors::Topology;
///
/// if let Ok(cores) = Topology::generate_cpu_cores() {
///     println!("There are {} cores on this host.", cores.len());
///     for c in &cores {
///         println!("Here is CPU Core number {}", c.attributes.get("processor").unwrap());
///     }
/// }
/// ```
Parses /proc/cpuinfo and creates instances of CPUCore.
Parses / proc / cpuinfo and creates instances of CPUCore .
pub fn generate_cpu_cores() -> Result<Vec<CPUCore>, String> {
        let cpuinfo = CpuInfo::new().unwrap();
        let mut cores = vec![];
        for id in 0..(cpuinfo.num_cores() - 1) {
            let mut info = HashMap::new();
            for (k, v) in cpuinfo.get_info(id).unwrap().iter() {
                info.insert(String::from(*k), String::from(*v));
            }
            cores.push(CPUCore::new(id as u16, info));
        }
        Ok(cores)
    }
pub fn generate_cpu_cores ( ) -> Result < Vec < CPUCore > , String > { let cpuinfo = CpuInfo :: new ( ) . unwrap ( ) ; let mut cores = vec ! [ ] ; for id in 0 .. ( cpuinfo . num_cores ( ) - 1 ) { let mut info = HashMap :: new ( ) ; for ( k , v ) in cpuinfo . get_info ( id ) . unwrap ( ) . iter ( ) { info . insert ( String :: from ( * k ) , String :: from ( * v ) ) ; } cores . push ( CPUCore :: new ( id as u16 , info ) ) ; } Ok ( cores ) }
Parses /proc/cpuinfo and creates instances of CPUCore.
Parses / proc / cpuinfo and creates instances of CPUCore .
examples
```
use scaphandre::sensors::Topology.

if let Ok(cores) = Topology::generate_cpu_cores() {
println!("There are {} cores on this host.", cores.len());
for c in &cores {
println!("Here is CPU Core number {}", c.attributes.get("processor").unwrap());
}
}
```
` ` ` use scaphandre :: sensors :: Topology . if let Ok ( cores ) = Topology :: generate_cpu_cores () { println! ( " There are {} cores on this host . " cores . len () ) ; for c in &cores { println! ( " Here is CPU Core number {} " c . attributes . get ( " processor " ) . unwrap () ) ; } } ` ` `