Expand description
§platform-info
A simple cross-platform way to get information about the currently running system.
§Examples
This simple example:
// examples/ex.rs
// * use `cargo run --example ex` to execute this example
// spell-checker:ignore (API) nodename osname sysname
use platform_info::*;
fn main() {
let info = PlatformInfo::new().expect("Unable to determine platform info");
// println!("info={:#?}", info);
println!("{}", info.sysname().to_string_lossy());
println!("{}", info.nodename().to_string_lossy());
println!("{}", info.release().to_string_lossy());
println!("{}", info.version().to_string_lossy());
println!("{}", info.machine().to_string_lossy());
println!("{}", info.processor().to_string_lossy());
println!("{}", info.osname().to_string_lossy());
}should display something like:
Linux
hostname
5.10.0-8-amd64
#1 SMP Debian 5.10.46-4 (2021-08-03)
x86_64
x86_64
GNU/LinuxUsing
cargo run --example exwill build and execute this example code.
§WASI
To cross-compile and run the example under WASI, first install wasmtime:
curl https://wasmtime.dev/install.sh -sSf | bashThen build and run:
cargo build --target wasm32-wasip1 --example ex
wasmtime target/wasm32-wasip1/debug/examples/ex.wasmThis should display:
wasi
localhost
0.0.0
0.0.0
wasm32
wasm32
WASIOther examples can be found in the examples directory.
§License
platform-info is licensed under the MIT License.
Structs§
- Platform
Info - Handles initial retrieval and holds cached information for the current platform (a Unix-like OS in this case).
- UTSName
- Contains information about the current computer system.
Traits§
- Platform
InfoAPI - Defines the full API for
PlatformInfo. - UNameAPI
- Defines a trait API providing
uname(aka “Unix name”) style platform information.
Type Aliases§
- Platform
Info Error - The common error type for
PlatformInfoAPI. Standard thread-safe error type (boxed to allow translation for anystd::error::Errortype)