Skip to main content

ImportResolver

Trait ImportResolver 

Source
pub trait ImportResolver: Send + Sync {
    // Required method
    fn resolve(
        &self,
        raw: &str,
        source_dir: &Path,
        project_root: &Path,
    ) -> Option<PathBuf>;

    // Provided method
    fn clear_cache(&self) { ... }
}
Expand description

Stateful import path resolution seam.

Implementors resolve a raw import string to an on-disk path within a project. The interface is stateful (takes &self) to allow implementors to cache config file reads (tsconfig.json, go.mod, sys.path) on first use.

Required Methods§

Source

fn resolve( &self, raw: &str, source_dir: &Path, project_root: &Path, ) -> Option<PathBuf>

Provided Methods§

Source

fn clear_cache(&self)

Invalidate any memoized filesystem state or configuration caches.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§