ffs_os_type 2.3.0

Detect the operating system type
Documentation
  • Coverage
  • 17.65%
    3 out of 17 items documented1 out of 3 items with examples
  • Size
  • Source code size: 28.83 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.15 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • alexsunxl/os_type
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • alexsunxl

Rust

os_type

Rust library to detect the operating system type, because sometimes you need to know.

Usage

Include this into your Cargo.toml:

[dependencies]
os_type="2.3"

In your code:

extern crate os_type;
let os = os_type::current_platform();
println!("Type: {:?}", os.os_type);
println!("Version: {}", os.version);

Or to provide different handling on different operating systems:

match os_type::current_platform().os_type {
  os_type::OSType::OSX => {
    println!("This is probably an apple laptop!");
  }
  os_type::OSType::Ubuntu => {
    println!("This is running Ubuntu Linux!");
  }
  _ => {
    println!("Unknown Operating System");
  }
}

Using os_type::current_platform().os_type, expect one of these return values:

  • Unknown
  • Redhat
  • CentOS
  • OSX
  • Ubuntu
  • Debian
  • Arch
  • Manjaro
  • Alpine
  • Deepin

If you need support for more OS types, please consider opening a Pull Request.

Requirements

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

Contributing

Bug reports and pull requests are welcome on GitHub. You can find more information about contributing in the CONTRIBUTING.md. This project is intended to be a safe, welcoming space for collaboration and discussion, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

MIT