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§
Sourcefn load(
&mut self,
scope: &mut ModuleScope<'_>,
name: &str,
attributes: &ModuleImportAttributes,
) -> Result<ModuleSource, Value>
fn load( &mut self, scope: &mut ModuleScope<'_>, name: &str, attributes: &ModuleImportAttributes, ) -> Result<ModuleSource, Value>
The module named name (normalized).
Provided Methods§
Sourcefn normalize(
&mut self,
scope: &mut ModuleScope<'_>,
referrer: &str,
specifier: &str,
attributes: &ModuleImportAttributes,
) -> Result<String, Value>
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".