https://github.com/macchina-cli/libmacchina
A library providing access to all sorts of system information.
https://github.com/macchina-cli/libmacchina
cross-platform fetch library system-information
Last synced: 8 months ago
JSON representation
A library providing access to all sorts of system information.
- Host: GitHub
- URL: https://github.com/macchina-cli/libmacchina
- Owner: Macchina-CLI
- License: mit
- Created: 2021-03-22T22:01:40.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-02-01T20:39:16.000Z (12 months ago)
- Last Synced: 2025-05-10T12:15:43.217Z (9 months ago)
- Topics: cross-platform, fetch, library, system-information
- Language: Rust
- Homepage: https://crates.io/crates/libmacchina
- Size: 683 KB
- Stars: 76
- Watchers: 3
- Forks: 20
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
libmacchina
A library providing access to all sorts of system information.
Linux • macOS • Windows • NetBSD • FreeBSD • Android • OpenWrt
### 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:
```toml
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
```rust
// 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]
}
```