pub enum HalError {
NoSuchAdapter(u32),
UnsupportedFeatures {
missing: Features,
},
InvalidHandle {
kind: &'static str,
bits: u64,
},
ForeignObject {
kind: &'static str,
bits: u64,
},
OutOfDeviceMemory,
OutOfHostMemory,
DeviceLost(String),
ShaderCompilation(String),
PipelineCreation(String),
InvalidDescriptor(String),
Unsupported {
backend: BackendKind,
what: &'static str,
},
Backend(String),
}Expand description
A backend operation failed.
Variants§
NoSuchAdapter(u32)
No adapter with that index exists.
UnsupportedFeatures
The chosen adapter lacks features the caller required.
missing is the exact gap, from
DeviceCaps::missing — so the log line
says which capability to go look up, not merely that something was
absent.
InvalidHandle
A handle did not resolve: it was destroyed, never created, or belongs to a different device.
The generational Handle makes this a clean
failure rather than an alias to whatever took the slot; see
crcbl-core’s handle module.
Fields
bits: u64The handle’s packed bits, from
Handle::to_bits.
ForeignObject
A handle resolved, but it belongs to a different Instance or
Device than the one it was given to.
Distinct from HalError::InvalidHandle because the causes and the
fixes differ: a stale handle means “you kept this too long”, a foreign
one means “you crossed two objects that never met”. Both are caller
bugs; neither may be undefined behaviour.
Handle bits are only unique within the backend that issued them, so two
instances will hand out identical bits. Detecting this is therefore an
implementation obligation on backends, not a property of the handle —
see crate::device for the required mechanism.
OutOfDeviceMemory
Device memory exhausted.
OutOfHostMemory
Host memory exhausted.
DeviceLost(String)
The device was lost — driver reset, GPU hang, TDR, or the browser reclaiming the context. Everything created from it is dead.
ShaderCompilation(String)
SPIR-V rejected, or cross-compilation to MSL/DXIL/WGSL failed.
PipelineCreation(String)
The pipeline state was rejected by the driver.
InvalidDescriptor(String)
A descriptor field was out of range or self-inconsistent — a caller bug, which is why the message is expected to name the field.
Unsupported
The operation is real but this backend cannot do it. Distinct from
HalError::UnsupportedFeatures, which is about a device.
Backend(String)
Anything else the backend wants to report verbatim.
Implementations§
Source§impl HalError
impl HalError
Sourcepub fn invalid_handle<T>(kind: &'static str, handle: Handle<T>) -> Self
pub fn invalid_handle<T>(kind: &'static str, handle: Handle<T>) -> Self
Builds an HalError::InvalidHandle from a typed handle.
Backends call this in their handle-lookup path so the error carries the
same bits that appear in Handle’s Debug output.
Trait Implementations§
Source§impl Error for HalError
impl Error for HalError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()