Crate platform_info

source ·
Expand description 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.


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

platform-info = "2"


// examples/
// * 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); // 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.


  • Handles initial retrieval and holds cached information for the current platform (a Unix-like OS in this case).
  • Contains information about the current computer system.


Type Definitions