pub struct CpuInfo {
pub fields: HashMap<String, String>,
pub cpus: Vec<HashMap<String, String>>,
}
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§
source§impl CpuInfo
impl 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
If the field is not found in the set of CPU-specific fields, then it is returned from the set of common fields.
Returns None if the requested cpu index is not found, or if the field 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§
source§impl<'de> Deserialize<'de> for CpuInfo
impl<'de> Deserialize<'de> for CpuInfo
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl FromBufRead for CpuInfo
impl FromBufRead for CpuInfo
fn from_buf_read<R: BufRead>(r: R) -> ProcResult<Self>
Auto Trait Implementations§
impl Freeze for CpuInfo
impl RefUnwindSafe for CpuInfo
impl Send for CpuInfo
impl Sync for CpuInfo
impl Unpin for CpuInfo
impl UnwindSafe for CpuInfo
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)