Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/williamanimate/sysinfo_dot_h

a tiny sys/sysinfo.h wrapper in rust
https://github.com/williamanimate/sysinfo_dot_h

Last synced: 14 days ago
JSON representation

a tiny sys/sysinfo.h wrapper in rust

Awesome Lists containing this project

README

        

# sysinfo dot h

A tiny wrapper in Rust

## How?

Quick start:

```rust
use sysinfo_dot_h::try_collect;

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

or

```rust
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:

```c
#include
int main() {
struct sysinfo *info;
sysinfo(info);
}
```

The [sysinfo](https://crates.io/crates/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.