11 releases (stable)

2.0.4 Sep 28, 2024
2.0.3 Apr 11, 2024
2.0.2 Jul 12, 2023
1.0.2 Jan 9, 2023
0.0.1 Jul 27, 2018

#23 in Operating systems

Download history 22413/week @ 2024-07-20 23222/week @ 2024-07-27 23463/week @ 2024-08-03 22071/week @ 2024-08-10 26405/week @ 2024-08-17 23626/week @ 2024-08-24 26884/week @ 2024-08-31 27987/week @ 2024-09-07 26402/week @ 2024-09-14 26912/week @ 2024-09-21 22244/week @ 2024-09-28 26294/week @ 2024-10-05 28012/week @ 2024-10-12 26682/week @ 2024-10-19 24231/week @ 2024-10-26 22227/week @ 2024-11-02

104,841 downloads per month
Used in 32 crates (13 directly)

MIT license

79KB
1K SLoC

platform-info

Crates.io License CodeCov

A simple cross-platform way to get information about the currently running system.

Examples

This simple example:

// examples/ex.rs
// * use `cargo run --example ex` to execute this example

// spell-checker:ignore (API) nodename osname sysname

use platform_info::*;

fn main() {
    let info = PlatformInfo::new().expect("Unable to determine platform info");
    // println!("info={:#?}", info);

    println!("{}", info.sysname().to_string_lossy());
    println!("{}", info.nodename().to_string_lossy());
    println!("{}", info.release().to_string_lossy());
    println!("{}", info.version().to_string_lossy());
    println!("{}", info.machine().to_string_lossy());
    println!("{}", info.osname().to_string_lossy());
}

should display something like:

Linux
hostname
5.10.0-8-amd64
#1 SMP Debian 5.10.46-4 (2021-08-03)
x86_64
GNU/Linux

Using cargo run --example ex will build and execute this example code.

Other examples can be found in the examples directory.

License

platform-info is licensed under the MIT License.

Dependencies

~220KB