pub struct BackendId { /* private fields */ }Expand description
Stable provider identifier for logs and explicit selection.
Identity is stored inline as fixed-capacity UTF-8 rather than
&'static str, because accelerator backends (CUDA, HIP, Vulkan) enumerate
their devices at runtime and cannot produce 'static text without leaking.
Keeping the value inline preserves Copy, so BackendId can continue to
live inside GeomError variants and DevicePreference without forcing an
allocation or a lifetime onto the error type.
Implementations§
Source§impl BackendId
impl BackendId
Sourcepub const fn new(value: &str) -> Self
pub const fn new(value: &str) -> Self
Construct an identifier known at compile time.
§Panics
Panics if value exceeds BackendId::CAPACITY bytes. This is a
const fn, so an over-long literal fails the build rather than a test
run. Use BackendId::try_new for runtime-derived text.
Sourcepub fn try_new(value: &str) -> Result<Self, BackendIdTooLong>
pub fn try_new(value: &str) -> Result<Self, BackendIdTooLong>
Construct an identifier from runtime-derived text, such as a driver-enumerated device name.
§Errors
Returns BackendIdTooLong when the text exceeds
BackendId::CAPACITY bytes. The identity is never truncated.