Expand description
Apple platform definitions from LLVM’s MachO.def.
This module exposes two closely related types:
-
ApplePlatform— aCopyenum whose variants map 1-to-1 to LLVM’sMachO::PlatformTypeidentifiers. It is the primary API surface: parse from a Rust target triple, look up an SDK name, or navigate the simulator/device relationship. -
Platform— a plainCopystruct of&'static strandu32fields that carries the raw LLVM metadata for a single platform (the data that lives in thePLATFORM(…)macro rows inMachO.def). Obtain one viaApplePlatform::metadata()orPlatform::from(platform).
§Error handling
All fallible constructors return ParsePlatformError on failure. It
implements both Display and std::error::Error, so it composes naturally
with anyhow, thiserror, or plain ? propagation.
§Examples
use apple_platforms::platform::ApplePlatform;
// Parse from a Rust target triple
let sim = ApplePlatform::from_rust_triple("aarch64-apple-ios-sim").unwrap();
assert_eq!(sim, ApplePlatform::IOSSimulator);
assert!(sim.is_simulator());
assert!(!sim.is_device());
// Navigate to the device platform
let device = sim.device();
assert_eq!(device, ApplePlatform::IOS);
// Navigate back to the simulator
assert_eq!(device.simulator(), Some(ApplePlatform::IOSSimulator));
// SDK name for xcrun
assert_eq!(sim.sdk(), Some("iphonesimulator"));
// Iterate all platforms
let count = ApplePlatform::iter().count();
assert_eq!(count, 13); // Unknown + 12 real platforms
// Sort by Mach-O ID (PartialOrd / Ord)
let mut platforms = vec![ApplePlatform::XrOS, ApplePlatform::MacOS];
platforms.sort();
assert_eq!(platforms[0], ApplePlatform::MacOS);Source: https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/BinaryFormat/MachO.def
Structs§
- Parse
Platform Error - Error returned when a platform name, ID, or target triple cannot be recognised as a known Apple platform.
- Platform
- Static metadata for a single Apple platform.
Enums§
- Apple
Platform - Apple platform enumeration.