Skip to main content

ShaderBuildError

Enum ShaderBuildError 

Source
#[non_exhaustive]
pub enum ShaderBuildError { InvalidName { path: PathBuf, component: String, }, NameCollision { first: PathBuf, second: PathBuf, kind: &'static str, name: String, }, ReservedName { path: PathBuf, name: String, }, ReservedImport { path: PathBuf, import_path: String, name: String, }, OutsideRoot { path: PathBuf, }, BindingLine { path: PathBuf, line: usize, text: String, reason: &'static str, }, UnsupportedBinding { path: PathBuf, line: usize, text: String, reason: &'static str, }, ModuleBinding { path: PathBuf, line: usize, text: String, }, BindingGap { path: PathBuf, indices: Vec<u32>, }, Compose { message: String, }, Io { path: PathBuf, source: Error, }, Environment { variable: &'static str, }, }
Expand description

Reason a shader build fails.

Debug writes the same text as Display, so a build script that returns the error shows its guidance.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

InvalidName

A component of a .wgsl file’s path below the shader root is not a Rust identifier, or is a keyword.

The same error reports an entry point whose ShaderEntry variant is not a Rust identifier, as self_.wgsl gives Self.

Fields

§path: PathBuf

Shader file.

§component: String

Path component or ShaderEntry variant that was rejected, or the whole relative path when one of its components is ., .. or not valid Unicode.

§

NameCollision

Two shaders give the same Rust name, or one shader’s module contains another shader’s module.

Fields

§first: PathBuf

Earlier shader of the two, in entry order.

§second: PathBuf

Later shader of the two.

§kind: &'static str

Kind of the name: module, variant for a ShaderEntry variant, or constant for a binding constant.

§name: String

Name the two shaders share.

§

ReservedName

A shader path or root that uses a reserved name.

The name henad is reserved regardless of case, for the last component of the shader root and for every component of a .wgsl file’s path below it. A name the generated bindings use, such as wgpu or _root, is reserved for the first component of a .wgsl path.

Fields

§path: PathBuf

Shader root, or the shader file whose path uses the name.

§name: String

Reserved name, henad in lower case or a name the generated bindings use.

§

ReservedImport

A file imported through an import path that makes it the module name at the root of the generated bindings, where name is henad in any letter case or a name the generated bindings use.

The bindings name a quoted import after the stem of its file name. #import "std.inc" gives the module std.

Fields

§path: PathBuf

Imported file.

§import_path: String

Import path that reached the file, with its quotes when quoted.

§name: String

First component of the module path the bindings give the file.

§

OutsideRoot

An entry point given to ShaderBuild::entry_point lies outside the shader root.

Fields

§path: PathBuf

Absolute path of the entry point, as given.

§

BindingLine

A line holding @binding or @group in a form that the binding parser does not accept.

Fields

§path: PathBuf

Entry point the line belongs to.

§line: usize

Line number, counted from 1.

§text: String

Text of the line, trimmed and without its comments.

§reason: &'static str

Reason the line is rejected, as in “var< has no closing >”.

§

UnsupportedBinding

A @group(0) binding of a kind no Henad pass binds: a sampler, a sampled texture, or an address space other than uniform, storage, read and storage, read_write.

Fields

§path: PathBuf

Entry point the line belongs to.

§line: usize

Line number, counted from 1.

§text: String

Text of the line, trimmed and without its comments.

§reason: &'static str

Kind of the binding, as in “a sampled texture or a sampler”.

§

ModuleBinding

A file that is not an entry point declares a binding on the given line.

Such a file is a module, with a #define_import_path line, or another file a shader imports.

Fields

§path: PathBuf

Module or imported file.

§line: usize

Line number, counted from 1.

§text: String

Text of the line, trimmed and without its comments.

§

BindingGap

The @group(0) indices of a shader, sorted, do not run from 0 with no gap or repeat.

Fields

§path: PathBuf

Entry point the indices belong to.

§indices: Vec<u32>

@binding indices of the shader’s @group(0) lines, sorted.

§

Compose

wgsl_bindgen could not compose the shaders or generate their bindings.

Fields

§message: String

Message of the wgsl_bindgen error or panic, or a message that lists the files of an import cycle.

§

Io

A file or directory could not be read or written.

Fields

§path: PathBuf

File or directory the operation failed on.

§source: Error

Error from the operating system.

§

Environment

Cargo did not set a variable a build script reads.

Fields

§variable: &'static str

Name of the variable, as in OUT_DIR.

Trait Implementations§

Source§

impl Debug for ShaderBuildError

Source§

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

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

impl Display for ShaderBuildError

Source§

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

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

impl Error for ShaderBuildError

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

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToSmolStr for T
where T: Display + ?Sized,

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

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more