Operating system information with os_info
-
os_info
-
os_type
-
architecture
[package]
name = "os-information"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
os_info = "3.7.0"
fn main() { 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()); println!("Architecture: {}", info.architecture().unwrap()); }
OS information: Ubuntu 23.10 (mantic) [64-bit]
Type: Ubuntu
Version: 23.10
Bitness: 64-bit
Architecture: x86_64