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 display_name(&self, _path: &ModulePath) -> Option<String> { ... }
    fn fs_path(
        &self,
        _module_path: &ModulePath,
    ) -> Result<PathBuf, ResolveError> { ... }
    fn module_path(&self, _fs_path: &Path) -> Result<ModulePath, ResolveError> { ... }
    fn canonical_path(&self, path: &ModulePath) -> ModulePath { ... }
}
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 display_name(&self, _path: &ModulePath) -> Option<String>

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

Source

fn fs_path(&self, _module_path: &ModulePath) -> Result<PathBuf, ResolveError>

Get the filesystem path of the module path. Implementing this is optional.

Source

fn module_path(&self, _fs_path: &Path) -> Result<ModulePath, ResolveError>

Get the module path of the filesystem path. Implementing this is optional.

Source

fn canonical_path(&self, path: &ModulePath) -> ModulePath

Get the canonical form of a module path.

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 &T

Source§

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

Implementors§