#system #fetch #library

libmacchina

A library that can fetch all sorts of system information

121 releases (57 stable)

6.1.1 Apr 28, 2022
6.1.0 Jan 27, 2022
5.0.4 Jan 1, 2022
5.0.3 Dec 26, 2021
0.1.3 Mar 22, 2021

#76 in Operating systems

Download history 84/week @ 2022-04-21 980/week @ 2022-04-28 810/week @ 2022-05-05 2081/week @ 2022-05-12 589/week @ 2022-05-19 846/week @ 2022-05-26 1195/week @ 2022-06-02 117/week @ 2022-06-09 145/week @ 2022-06-16 144/week @ 2022-06-23 119/week @ 2022-06-30 388/week @ 2022-07-07 243/week @ 2022-07-14 459/week @ 2022-07-21 256/week @ 2022-07-28 269/week @ 2022-08-04

1,369 downloads per month
Used in 5 crates

MIT license

170KB
4K 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 = "6"

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–51MB
~884K SLoC