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§
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 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, _module_path: &ModulePath) -> Result<PathBuf, ResolveError>
fn fs_path(&self, _module_path: &ModulePath) -> Result<PathBuf, ResolveError>
Get the filesystem path of the module path. Implementing this is optional.
Sourcefn module_path(&self, _fs_path: &Path) -> Result<ModulePath, ResolveError>
fn module_path(&self, _fs_path: &Path) -> Result<ModulePath, ResolveError>
Get the module path of the filesystem path. Implementing this is optional.
Sourcefn canonical_path(&self, path: &ModulePath) -> ModulePath
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".