platforms crate provides information about the target platforms supported by Rust.
You can query platform tier as well as the common
cfg values such as OS, pointer width, endianness, and others - for any target triple, at runtime.
It also provides a list of all valid targets, and emums of architectures and operating systems supported by Rust. We use the OS and Arch enums in
cargo-audit to specify affected OSs and architectures.
What's new in v3.0
Most notably, the crate is now automatically generated from the documentation and the latest nightly
rustc. This makes information very easy to keep up to date, and rules out human error.
The list of provided properties has been expanded: pointer width and endianness have been added in this release. The
Platform struct has been marked
#[non_exhaustive] to allow adding more platform properties in the future without breaking the API.
cfg-based platform detection code has been dropped. I've implemented a better approach to platform detection as a separate crate,
current_platform. It can be combined with
platforms if you need to know the properties of the platform your code is running on.