Skip to main content

SystemInfoInterface

Trait SystemInfoInterface 

Source
pub trait SystemInfoInterface {
    // Required methods
    fn boot_time_secs(&self) -> ProcResult<u64>;
    fn ticks_per_second(&self) -> u64;
    fn page_size(&self) -> u64;
    fn is_little_endian(&self) -> bool;

    // Provided method
    fn boot_time(&self) -> ProcResult<DateTime<Local>> { ... }
}
Expand description

Auxiliary system information interface.

A few function in this crate require some extra system info to compute their results. For example, the crate::process::Stat::rss_bytes() function needs to know the page size. Since procfs-core only parses data and never interacts with a real system, this SystemInfoInterface is what allows real system info to be used.

If you are a user of the procfs crate, you’ll normally use the [procfs::WithCurrentSystemInfo] trait. For example:

use procfs::WithCurrentSystemInfo;

let me = procfs::process::Process::myself().unwrap();
let stat = me.stat().unwrap();
let bytes = stat.rss_bytes().get();

However, imagine that you captured a process’s stat info, along with page size:

let stat = procfs_core::process::Stat::from_read(stat_data).unwrap();

let system_info = procfs_core::ExplicitSystemInfo {
    boot_time_secs: 1692972606,
    ticks_per_second: 100,
    page_size: 4096,
    is_little_endian: true,
};

let rss_bytes = stat.rss_bytes().with_system_info(&system_info);

Required Methods§

Source

fn boot_time_secs(&self) -> ProcResult<u64>

Source

fn ticks_per_second(&self) -> u64

Source

fn page_size(&self) -> u64

Source

fn is_little_endian(&self) -> bool

Whether the system is little endian (true) or big endian (false).

Provided Methods§

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§