21 releases (13 stable)

✓ Uses Rust 2018 edition

new 1.3.3 Jan 24, 2020
1.2.0 Dec 11, 2019
1.1.3 Oct 22, 2019
1.1.1 Mar 22, 2019
0.4.0 Nov 12, 2017

#7 in Operating systems

Download history 4449/week @ 2019-10-13 7879/week @ 2019-10-20 6263/week @ 2019-10-27 5541/week @ 2019-11-03 4537/week @ 2019-11-10 5108/week @ 2019-11-17 1835/week @ 2019-11-24 4063/week @ 2019-12-01 3526/week @ 2019-12-08 5374/week @ 2019-12-15 2303/week @ 2019-12-22 2538/week @ 2019-12-29 1741/week @ 2020-01-05 7749/week @ 2020-01-12 6354/week @ 2020-01-19

18,617 downloads per month
Used in 19 crates (7 directly)

MIT license

210KB
1K SLoC

os_info

Status: Travis Build Status CircleCI Build Status AppVeyor Build Status

Project info: Docs.rs Latest Version License

Project details: LoC rust 1.33+ required dependency status

Overview

Library for detecting the operating system type and version.

Based on os_type. The main difference of os_info is that this library separates completely incompatible operating systems by conditional compilation and uses specific system API whenever is possible.

Usage

To use this crate, add os_info as a dependency to your project's Cargo.toml:

[dependencies]
os_info = "1.3.3"

Example

let info = os_info::get();

// Print full information:
println!("OS information: {}", info);

// Print information separately:
println!("Type: {}", info.os_type());
println!("Version: {}", info.version());
println!("Bitness: {}", info.bitness());

Right now, the following operating system types can be returned:

  • Unknown
  • Android
  • Emscripten
  • Linux
  • Redhat
  • RedHatEnterprise
  • Ubuntu
  • Debian
  • Arch
  • CentOS
  • Fedora
  • Amazon
  • Alpine
  • Macos
  • Redox
  • Windows

If you need support for more OS types, I am looking forward to your Pull Request.

Requirements

On Linux based systems this library requires that lsb_release is installed.

License

os_info is licensed under the MIT license. See LICENSE for the details.

Dependencies

~0.7–1.5MB
~34K SLoC