Trait ModuleLoader

Source
pub trait ModuleLoader: Default {
    // Required methods
    fn load(
        &mut self,
        name: &Identifier,
        from: Option<FileId>,
        store: &mut impl ModuleStore,
        recursive: bool,
    ) -> Result<Identifier, Error>;
    fn resolver(&self) -> &impl ModuleResolver;
    fn get_file_id(&self, name: &Identifier) -> Option<FileId>;
    fn get_source(&self, file_id: FileId) -> Option<Source>;
    fn report(&self, diagnostic: &Diagnostic) -> Result<(), Error>;
    fn reporter_done(
        &self,
        top_module_name: Option<String>,
    ) -> Result<ReportCounters, Error>;
    fn set_severity_filter(&mut self, filter: SeverityFilter);

    // Provided methods
    fn get_source_by_name(&self, name: &Identifier) -> Option<Source> { ... }
    fn has_source(&self, file_id: FileId) -> bool { ... }
}
Expand description

A loader instance is responsible for resolving a module into a resource URL and parsing it into memory. Note that the loader does not return the module instance itself but rather the module’s name parsed from the resource, the module itself is inserted into the cache.

Required Methods§

Source

fn load( &mut self, name: &Identifier, from: Option<FileId>, store: &mut impl ModuleStore, recursive: bool, ) -> Result<Identifier, Error>

Resolve name into a resource identifier (URL) and parse into memory. The loader will check the store first to see if the module is already loaded, and will add the module into the store after parsing. The value of recursive tells the loader whether to also load the module’s dependencies as well.

Source

fn resolver(&self) -> &impl ModuleResolver

Returns the instance of ModuleResolver used by this loader.

Source

fn get_file_id(&self, name: &Identifier) -> Option<FileId>

Source

fn get_source(&self, file_id: FileId) -> Option<Source>

Source

fn report(&self, diagnostic: &Diagnostic) -> Result<(), Error>

Source

fn reporter_done( &self, top_module_name: Option<String>, ) -> Result<ReportCounters, Error>

Source

fn set_severity_filter(&mut self, filter: SeverityFilter)

Provided Methods§

Source

fn get_source_by_name(&self, name: &Identifier) -> Option<Source>

Source

fn has_source(&self, file_id: FileId) -> bool

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§