Skip to main content

ModuleLoader

Trait ModuleLoader 

Source
pub trait ModuleLoader {
    // Required method
    fn load(
        &self,
        specifier: &str,
        attributes: &[(String, String)],
        referrer: &str,
    ) -> Result<LoadedModule, String>;
}
Expand description

How the host turns a specifier into bytes.

The engine cannot do this itself: resolving ./x.js needs to know that the importer was a file, and where. A browser-shaped host would answer differently, so the host supplies this and the engine decides what to do with the bytes.

Required Methods§

Source

fn load( &self, specifier: &str, attributes: &[(String, String)], referrer: &str, ) -> Result<LoadedModule, String>

Resolve specifier relative to referrer and read it.

referrer is empty for the entry module.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§