3 unstable releases

0.2.1 Apr 14, 2024
0.2.0 Mar 23, 2024
0.1.0 Mar 18, 2024

#457 in Unix APIs

Download history 26/week @ 2024-07-07 1/week @ 2024-07-14 1/week @ 2024-07-21 10/week @ 2024-07-28 2/week @ 2024-08-04 16/week @ 2024-08-18 5/week @ 2024-08-25 3/week @ 2024-09-01 8/week @ 2024-09-08 32/week @ 2024-09-15 39/week @ 2024-09-22 34/week @ 2024-09-29 2/week @ 2024-10-06 23/week @ 2024-10-13

109 downloads per month

MIT license

8KB
62 lines

sysinfo dot h

A tiny <sys/sysinfo.h> wrapper in Rust

How?

Quick start:

use sysinfo_dot_h::try_collect;

let info = try_collect().unwrap();
dbg!(info.uptime); // uptime in seconds

or

use sysinfo_dot_h::collect;

let info = collect();
dbg!(info.uptime); // uptime in seconds

Why?

This makes it easier (and quicker) to port the following C code to rust:

#include <sys/sysinfo.h>
int main() {
    struct sysinfo *info;
    sysinfo(info);
}

The sysinfo crate was too slow for my use case (200 milliseconds) so I made my own.

Please note that unlike sysinfo, this crate only works on Linux, so if your application is cross platform it may not be favourable to use this crate.


lib.rs:

This crate uses raw FFI bindings to easily and quickly get and use the <sys/sysinfo.h> struct. Please read the README if you want to know more.

Internally, this crate calls unsafe {} because of FFI. You, the programmer, are ultimately responsible for any downtime in prod or similar

No runtime deps