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§
Sourcefn resolve_source<'a>(
&'a self,
path: &ModulePath,
) -> Result<Cow<'a, str>, ResolveError>
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§
Sourcefn resolve_module(
&self,
path: &ModulePath,
) -> Result<TranslationUnit, ResolveError>
fn resolve_module( &self, path: &ModulePath, ) -> Result<TranslationUnit, ResolveError>
Try to resolve a source file identified by a module path.
Sourcefn display_name(&self, _path: &ModulePath) -> Option<String>
fn display_name(&self, _path: &ModulePath) -> Option<String>
Get the display name of the module path. Implementing this is optional.
Sourcefn fs_path(&self, _path: &ModulePath) -> Option<PathBuf>
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".