Trait ModuleLoader

Source
pub trait ModuleLoader: Clone {
    // Required methods
    fn resolve(&self, caller_module: &str, module: &str) -> Option<String>;
    fn load(&self, module: &str) -> Option<String>;
}
Expand description

The embedder needs to implement this trait to specify how to resolve import paths

Required Methods§

Source

fn resolve(&self, caller_module: &str, module: &str) -> Option<String>

Returns the name of the module where

  • caller_module is the module calling import
  • module is the argument passed to import
Source

fn load(&self, module: &str) -> Option<String>

Returns the source of the module

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl ModuleLoader for NoopModuleLoader

A module loader that always returns None