Skip to main content

SourceMap

Trait SourceMap 

Source
pub trait SourceMap {
    // Required methods
    fn item(&self, decl: &str) -> Option<&SourceMapEntry>;
    fn source(&self, path: &ModulePath) -> Option<&str>;
    fn display_name(&self, path: &ModulePath) -> Option<&str>;

    // Provided method
    fn default_source(&self) -> Option<&str> { ... }
}
Expand description

A SourceMap is a lookup from compiled WGSL to source WESL. It translates a mangled name into a module path and declaration name.

Using SourceMaps improves the readability of error diagnostics, by providing needed information to identify the originating code snippet, file name and declaration name. It is highly recommended to use them, but they can increase the compilation memory footprint, since they cache all loaded files.

Typically you record to a SourceMap by passing a SourceMapper as the Resolver and Mangler when compiling code.

Required Methods§

Source

fn item(&self, decl: &str) -> Option<&SourceMapEntry>

Get the module path and declaration name from a mangled name.

Source

fn source(&self, path: &ModulePath) -> Option<&str>

Get a module contents.

Source

fn display_name(&self, path: &ModulePath) -> Option<&str>

Get a module display name.

Provided Methods§

Source

fn default_source(&self) -> Option<&str>

Get the default module contents.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: SourceMap> SourceMap for Option<T>

Source§

fn item(&self, decl: &str) -> Option<&SourceMapEntry>

Source§

fn source(&self, path: &ModulePath) -> Option<&str>

Source§

fn display_name(&self, path: &ModulePath) -> Option<&str>

Source§

fn default_source(&self) -> Option<&str>

Implementors§