Skip to main content

ModuleResolver

Trait ModuleResolver 

Source
pub trait ModuleResolver: Clone + Default {
    // Required methods
    fn resolve(&self, module_name: &str) -> Result<String, ModuleError>;
    fn get_path(&self, module_name: &str) -> Result<String, ModuleError>;
    fn search_paths(&self) -> Vec<PathBuf>;
    fn set_search_paths(&mut self, paths: Vec<PathBuf>);

    // Provided methods
    fn canonical_name<'a>(&self, module_path: &'a str) -> &'a str { ... }
    fn is_immutable_module(&self, _module_path: &str) -> bool { ... }
}
Expand description

Core interface for resolving mq module source code by name.

Required Methods§

Source

fn resolve(&self, module_name: &str) -> Result<String, ModuleError>

Returns the source content of module_name.

Source

fn get_path(&self, module_name: &str) -> Result<String, ModuleError>

Returns the canonical path string for module_name (for diagnostics / LSP).

Source

fn search_paths(&self) -> Vec<PathBuf>

Returns the filesystem directories this resolver searches.

Source

fn set_search_paths(&mut self, paths: Vec<PathBuf>)

Replaces the filesystem search directories.

Provided Methods§

Source

fn canonical_name<'a>(&self, module_path: &'a str) -> &'a str

Returns the short identifier to store the module under.

For most resolvers this is module_path unchanged. HTTP-based resolvers strip the URL prefix and .mq suffix so that, for example, github.com/alice/mymod.mq@v1.0 becomes "mymod".

Source

fn is_immutable_module(&self, _module_path: &str) -> bool

Whether this module’s source is embedded in the current binary and therefore cannot change during the lifetime of an Engine.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§