Crate platform_info

source ·
Expand description

Crates.io License CodeCov

This crate provides the ability to retrieve information specific to your current platform via a cross-platform uname-type API (UNameAPI). Additional platform-specific information may be supplied within PlatformInfo.

§Usage

This crate is available on crate.io. So, to use it in your project, just add the following to your project’s Cargo.toml dependencies:

[dependencies]
platform-info = "2"

§Examples

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

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

use platform_info::{PlatformInfo, PlatformInfoAPI, UNameAPI};

fn main() {
    let info = PlatformInfo::new().expect("Unable to determine platform info");
    // println!("info={:#?}", info); // note: info *may* contain extra platform-specific fields

    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());
}

Other examples can be found in the examples directory of this crate and in the uutils/coreutils implementation of uname.

Structs§

Traits§

Type Aliases§