24 releases (stable)

✓ Uses Rust 2018 edition

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

#7 in Operating systems

Download history 3973/week @ 2019-12-02 3594/week @ 2019-12-09 5546/week @ 2019-12-16 2201/week @ 2019-12-23 2533/week @ 2019-12-30 1781/week @ 2020-01-06 7806/week @ 2020-01-13 6666/week @ 2020-01-20 5449/week @ 2020-01-27 5532/week @ 2020-02-03 6556/week @ 2020-02-10 5571/week @ 2020-02-17 5961/week @ 2020-02-24 6034/week @ 2020-03-02 8505/week @ 2020-03-09 5627/week @ 2020-03-16

23,048 downloads per month
Used in 31 crates (7 directly)

MIT license

57KB
1.5K SLoC

os_info

Status: CI

Project info: Docs.rs Latest Version License

Project details: LoC rust 1.41+ 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 = "2.0.2"

This project has serde as an optional dependency, so if you don't need it, then you can speed up compilation disabling it:

[dependencies]
os_info = { version = "2.0.0", default-features = false }

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
  • SUSE Linux Enterprise
  • openSUSE
  • 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.2MB
~27K SLoC