Expand description
Represents the data from /proc/cpuinfo
.
The fields
field stores the fields that are common among all CPUs. The cpus
field stores
CPU-specific info.
For common fields, there are methods that will return the data, converted to a more appropriate
data type. These methods will all return None
if the field doesn’t exist, or is in some
unexpected format (in that case, you’ll have to access the string data directly).
Fields
fields: HashMap<String, String>
This stores fields that are common among all CPUs
cpus: Vec<HashMap<String, String>>
Implementations
sourceimpl CpuInfo
impl CpuInfo
sourcepub fn from_reader<R: Read>(r: R) -> ProcResult<CpuInfo>
pub fn from_reader<R: Read>(r: R) -> ProcResult<CpuInfo>
Get CpuInfo from a custom Read instead of the default /proc/cpuinfo
.
pub fn new() -> ProcResult<CpuInfo>
sourcepub fn num_cores(&self) -> usize
pub fn num_cores(&self) -> usize
Get the total number of cpu cores.
This is the number of entries in the /proc/cpuinfo
file.
sourcepub fn get_info(&self, cpu_num: usize) -> Option<HashMap<&str, &str>>
pub fn get_info(&self, cpu_num: usize) -> Option<HashMap<&str, &str>>
Get info for a specific cpu.
This will merge the common fields with the cpu-specific fields.
Returns None if the requested cpu index is not found.
sourcepub fn get_field(&self, cpu_num: usize, field_name: &str) -> Option<&str>
pub fn get_field(&self, cpu_num: usize, field_name: &str) -> Option<&str>
Get the content of a specific field associated to a CPU
Returns None if the requested cpu index is not found.
pub fn model_name(&self, cpu_num: usize) -> Option<&str>
pub fn vendor_id(&self, cpu_num: usize) -> Option<&str>
sourcepub fn physical_id(&self, cpu_num: usize) -> Option<u32>
pub fn physical_id(&self, cpu_num: usize) -> Option<u32>
May not be available on some older 2.6 kernels
pub fn flags(&self, cpu_num: usize) -> Option<Vec<&str>>
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for CpuInfo
impl Send for CpuInfo
impl Sync for CpuInfo
impl Unpin for CpuInfo
impl UnwindSafe for CpuInfo
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more