Crates.io | ffs_os_type |
lib.rs | ffs_os_type |
version | 2.3.0 |
source | src |
created_at | 2021-12-09 02:15:32.615165 |
updated_at | 2021-12-09 02:15:32.615165 |
description | Detect the operating system type |
homepage | |
repository | https://github.com/alexsunxl/os_type |
max_upload_size | |
id | 494926 |
size | 27,969 |
Rust library to detect the operating system type, because sometimes you need to know.
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:
If you need support for more OS types, please consider opening a Pull Request.
On Linux based systems this library requires that lsb_release is installed.
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.
MIT