Skip to main content

ModuleLoader

Trait ModuleLoader 

Source
pub trait ModuleLoader {
    // Required method
    fn load(
        &mut self,
        scope: &mut ModuleScope<'_>,
        name: &str,
        attributes: &ModuleImportAttributes,
    ) -> Result<ModuleSource, Value>;

    // Provided method
    fn normalize(
        &mut self,
        scope: &mut ModuleScope<'_>,
        referrer: &str,
        specifier: &str,
        attributes: &ModuleImportAttributes,
    ) -> Result<String, Value> { ... }
}
Expand description

The embedder’s module loader. Errors are values to throw, made through the ModuleScope.

Required Methods§

Source

fn load( &mut self, scope: &mut ModuleScope<'_>, name: &str, attributes: &ModuleImportAttributes, ) -> Result<ModuleSource, Value>

The module named name (normalized).

Provided Methods§

Source

fn normalize( &mut self, scope: &mut ModuleScope<'_>, referrer: &str, specifier: &str, attributes: &ModuleImportAttributes, ) -> Result<String, Value>

The normalized name of specifier imported by the module or script named referrer. The default is QuickJS’s: a specifier starting with . resolves against the referrer’s directory.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§