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§
Sourcefn item(&self, decl: &str) -> Option<&SourceMapEntry>
fn item(&self, decl: &str) -> Option<&SourceMapEntry>
Get the module path and declaration name from a mangled name.
Sourcefn source(&self, path: &ModulePath) -> Option<&str>
fn source(&self, path: &ModulePath) -> Option<&str>
Get a module contents.
Sourcefn display_name(&self, path: &ModulePath) -> Option<&str>
fn display_name(&self, path: &ModulePath) -> Option<&str>
Get a module display name.
Provided Methods§
Sourcefn default_source(&self) -> Option<&str>
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".