Skip to main content

Resolver

Trait Resolver 

Source
pub trait Resolver {
    // Required method
    fn resolve_source<'a>(
        &'a self,
        path: &ModulePath,
    ) -> Result<Cow<'a, str>, ResolveError>;

    // Provided methods
    fn resolve_module(
        &self,
        path: &ModulePath,
    ) -> Result<TranslationUnit, ResolveError> { ... }
    fn display_name(&self, _path: &ModulePath) -> Option<String> { ... }
    fn fs_path(&self, _path: &ModulePath) -> Option<PathBuf> { ... }
}
Expand description

A Resolver implements the module resolution algorithm: it returns a module contents associated with a module path.

Typically implementations of Resolver only implement Resolver::resolve_source.

Calls to Resolver functions must respect these preconditions:

  • the import path must not be relative.

Required Methods§

Source

fn resolve_source<'a>( &'a self, path: &ModulePath, ) -> Result<Cow<'a, str>, ResolveError>

Try to resolve a source file identified by a module path.

Provided Methods§

Source

fn resolve_module( &self, path: &ModulePath, ) -> Result<TranslationUnit, ResolveError>

Try to resolve a source file identified by a module path.

Source

fn display_name(&self, _path: &ModulePath) -> Option<String>

Get the display name of the module path. Implementing this is optional.

Source

fn fs_path(&self, _path: &ModulePath) -> Option<PathBuf>

Get the filesystem path of the module path. Implementing this is optional. Used by build scripts for dependency tracking.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T: Resolver + ?Sized> Resolver for Box<T>

Source§

impl<T: Resolver> Resolver for &T

Implementors§