135 releases (71 stable)

7.2.2 Mar 17, 2024
7.2.1 Oct 6, 2023
7.1.0 May 16, 2023
7.0.0 Mar 28, 2023
0.1.3 Mar 22, 2021

#113 in Operating systems

Download history 117/week @ 2023-12-22 110/week @ 2023-12-29 99/week @ 2024-01-05 117/week @ 2024-01-12 128/week @ 2024-01-19 107/week @ 2024-01-26 208/week @ 2024-02-02 148/week @ 2024-02-09 157/week @ 2024-02-16 201/week @ 2024-02-23 197/week @ 2024-03-01 236/week @ 2024-03-08 338/week @ 2024-03-15 318/week @ 2024-03-22 312/week @ 2024-03-29 164/week @ 2024-04-05

1,160 downloads per month
Used in 8 crates

MIT and maybe GPL-3.0-only

185KB
4.5K SLoC

libmacchina

A library providing access to all sorts of system information.

Linux • macOS • Windows • NetBSD • FreeBSD • Android • OpenWrt

version docs

Disclaimer

libmacchina utilizes unsafe code in the form of calls to system libraries that haven't been natively implemented in Rust, we do this for performance reasons.

Usage

Add the following to your project's Cargo.toml file:

libmacchina = "7"

Notes

On distributions like openSUSE that use the ndb RPM database format, librpm (which is usually provided by the rpm-devel package) is required for the RPM package count readout to work.

Examples

// Let's import two of the several available types.
use libmacchina::{GeneralReadout, MemoryReadout};

fn main() {
    // Let's import the GeneralReadout trait so we
    // can fetch some general information about the host.
    use libmacchina::traits::GeneralReadout as _;

    let general_readout = GeneralReadout::new();

    // There are many more metrics we can query
    // i.e. username, distribution, terminal, shell, etc.
    let cpu_cores = general_readout.cpu_cores().unwrap(); // 8 [logical cores]
    let cpu = general_readout.cpu_model_name().unwrap();  // Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
    let uptime = general_readout.uptime().unwrap();       // 1500 [in seconds]

    // Now we'll import the MemoryReadout trait to get an
    // idea of what the host's memory usage looks like.
    use libmacchina::traits::MemoryReadout as _;

    let memory_readout = MemoryReadout::new();

    let total_mem = memory_readout.total(); // 20242204 [in kB]
    let used_mem = memory_readout.used();   // 3894880 [in kB]
}

Dependencies

~0.7–48MB
~683K SLoC