Skip to main content

HalError

Enum HalError 

Source
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.

Fields

§missing: Features

Features requested but not present.

§

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

§kind: &'static str

Resource kind, e.g. "buffer".

§bits: u64

The 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.

Fields

§kind: &'static str

Resource kind, e.g. "surface".

§bits: u64

The handle’s packed bits.

§

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.

Fields

§backend: BackendKind

Backend that refused.

§what: &'static str

What was asked for.

§

Backend(String)

Anything else the backend wants to report verbatim.

Implementations§

Source§

impl HalError

Source

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 Debug for HalError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for HalError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for HalError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<HalError> for SurfaceError

Source§

fn from(source: HalError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> HalThreadSafe for T
where T: Send + Sync,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.