gpu-handle-types 0.2.0

Typed, owned native GPU resource handles (Vulkan, D3D11/12, Metal, OpenGL, CUDA, OpenCL, DMA-BUF, IOSurface, AHardwareBuffer, WebGPU, ...), cross-API sync points and video pixel formats, for passing GPU resources between libraries.
Documentation
// SPDX-License-Identifier: MIT OR Apache-2.0

//! `trybuild` UI tests — compile-time enforcement that the typed-newtype
//! handle wrappers can't be silently confused with each other.
//!
//! These are *compile-fail* tests: each `tests/ui/*.rs` file must FAIL to
//! compile, and its captured diagnostic must match `tests/ui/*.stderr`.
//! Run with `TRYBUILD=overwrite cargo test -p gpu-handle-types --test compile_fail`
//! to regenerate the `.stderr` snapshots after an intentional change.
//!
//! The `NtHandle` ≠ `KmtToken` invariant is part of the
//! handle-newtype contract — `NtHandle` wraps an `Arc<OwnedHandle>` (NT
//! kernel-object reference, `CloseHandle` on last drop); `KmtToken` is
//! a `u32` DXGI table id with no `CloseHandle` semantics. Conflating
//! them at any consumer site would leak a kernel handle or close an
//! unrelated one, so the type system must reject implicit conversions
//! between them. This test pins that guarantee against future drift —
//! if the two ever became interchangeable (say, one turned into a type
//! alias of the other), the UI files would compile, and trybuild reports
//! a compile-fail case that compiles as a failure.

#[cfg(windows)]
#[test]
fn nt_handle_kmt_token_not_interchangeable() {
    let t = trybuild::TestCases::new();
    t.compile_fail("tests/ui/nt_handle_into_kmt_token.rs");
    t.compile_fail("tests/ui/kmt_token_into_nt_handle.rs");
}