mln-rs-runtime 0.0.23

Part of mln-rs, a MapLibre map renderer written in Rust. Depend on mln-rs instead.
Documentation
//! Per-backend glue for [`super::target`] and [`super::local`]. Each
//! submodule is compiled only when its backend is enabled for the target.

// The matches over the backends' enums list a variant per backend that the
// build's features and target have, so whether their `_` arm is unreachable,
// or matches a single variant, and whether a `let` of one variant is
// irrefutable, depends on the build.
#![allow(
    unreachable_patterns,
    irrefutable_let_patterns,
    clippy::match_wildcard_for_single_variants,
    reason = "the backends' variants depend on the build's features and target"
)]

#[cfg(has_d3d12)]
pub(super) mod d3d12;
#[cfg(feature = "gl")]
pub(super) mod gl;
#[cfg(has_metal)]
pub(super) mod metal;
#[cfg(has_vulkan)]
pub(super) mod vulkan;
#[cfg(feature = "webgpu")]
pub(super) mod webgpu;

/// The adapter index from `adapter`, failing with `Unsupported` for backends
/// that name no GPU by UUID or LUID.
#[cfg(any(has_native_webgpu, has_metal, has_gl_device))]
pub(super) fn adapter_index(
    backend: super::target::BackendType,
    adapter: Option<super::target::Adapter>,
) -> Result<Option<usize>, mln_style::error::Error> {
    match adapter {
        None => Ok(None),
        Some(super::target::Adapter::Index(index)) => Ok(Some(index)),
        Some(_) => Err(mln_style::error::Error::unsupported(format!("{backend:?} names no GPU by UUID or LUID"))),
    }
}