Crate lscpu

Source
Expand description

§lscpu

Implementation of lscpu in rust

§Run a std example

cargo run --example std

This code can be runned also in a no-std environment.

§Cpu Data:

/// Represents the main CPU information obtained via CPUID instructions.
pub struct Cpu {
    /// Detected architecture (e.g., "x86_64").
    pub architecture: &'static str,
    /// Supported CPU operation modes (e.g., "32-bit, 64-bit").
    pub cpu_op_modes: &'static str,
    /// Physical and virtual address sizes.
    pub address_sizes: String,
    /// CPU byte order ("Little Endian" or "Big Endian").
    pub byte_order: &'static str,
    /// Total number of logical CPUs detected.
    pub cpu_count: u32,
    /// Number of online CPUs detected.
    pub on_line_cpu: u32,
    /// CPU vendor identifier.
    pub vendor_id: String,
    /// CPU model name.
    pub model_name: String,
    /// CPU family.
    pub cpu_family: u32,
    /// CPU model.
    pub cpu_model: u32,
    /// Indicates if the CPU is hybrid.
    pub is_hybrid: &'static str,
    /// Threads per core.
    pub threads_per_core: u32,
    /// Cores per socket.
    pub cores_per_socket: u32,
    /// Number of sockets detected.
    pub sockets: u32,
    /// CPU stepping.
    pub stepping: u32,
    /// Indicates if frequency boost is enabled.
    pub boost_enabled: &'static str,
}

Structs§

Cpu
Represents the main CPU information obtained via CPUID instructions.

Functions§

fix_result
Helper function to fix the result for certain topology queries.
get_address_sizes
Returns the physical and virtual address sizes of the CPU.
get_boost_enabled
Returns whether frequency boost is enabled (“enabled” or “disabled”).
get_byte_order
Returns the CPU byte order (“Little Endian” or “Big Endian”).
get_cores_per_socket
Returns the number of cores per socket.
get_cpu_architecture
Returns the detected CPU architecture (e.g., “x86_64”) using CPUID.
get_cpu_count
Returns the total number of logical CPUs detected.
get_cpu_family
Returns the CPU family number.
get_cpu_model
Returns the CPU model number.
get_cpu_op_modes
Returns the supported CPU operation modes (e.g., “32-bit, 64-bit”).
get_hybrid_flag
Returns whether the CPU is hybrid (“hybrid” or “no”).
get_model_name
Returns the CPU model name as a string.
get_on_line_cpu
Returns the number of online CPUs detected.
get_sockets
Returns the number of sockets detected.
get_stepping
Returns the CPU stepping value.
get_threads_per_core
Returns the number of threads per core.
get_vendor_id
Returns the CPU vendor identifier as a string.