[][src]Trait wlambda::compiler::ModuleResolver

pub trait ModuleResolver {
    fn resolve(
        &mut self,
        global: GlobalEnvRef,
        path: &[String]
    ) -> Result<HashMap<String, VVal>, ModuleLoadError>; }

This trait is responsible for loading modules and returning a collection of name->value mappings for a module name.

See also GlobalEnv::set_resolver() about how to configure the global environment to use you trait implementation.

There is a default implementation named LocalFileModuleResolver, which loads the modules from files.

Required methods

fn resolve(
    &mut self,
    global: GlobalEnvRef,
    path: &[String]
) -> Result<HashMap<String, VVal>, ModuleLoadError>

Resolves the path to a HashMap of names -> VVal. Where you obtain this mapping from is completely up to you. You can statically define these, load them from a JSON file, load them by executing another WLambda script or whatever you fancy.

See LocalFileModuleResolver as example on how to implement this.

Loading content...

Implementors

impl ModuleResolver for LocalFileModuleResolver[src]

Loading content...