Skip to main content

ProjectResolver

Trait ProjectResolver 

Source
pub trait ProjectResolver:
    Send
    + Sync
    + Debug {
    // Required methods
    fn for_path(&self, path: &Path) -> Project;
    fn set_pwd(&self, pwd: PathBuf);
    fn set_markers(&self, markers: Vec<String>);
    fn invalidate(&self);
}
Expand description

Resolves paths to projects.

&self throughout and Send + Sync, so any thread may ask: this is consulted off the actor thread by subsystems that spawn processes, and the cache write takes a short mutex never held across an await.

Required Methods§

Source

fn for_path(&self, path: &Path) -> Project

The project containing path, which may be a file or a directory. Total — see the module docs.

Source

fn set_pwd(&self, pwd: PathBuf)

Re-point the working directory the ProjectKind::Pwd fallback uses. Called on :cd. Drops the cache, because entries that fell back to the old pwd are now wrong.

Source

fn set_markers(&self, markers: Vec<String>)

Replace the marker set. Called when project.root-markers changes, and at boot once config has been applied.

The markers cannot be fixed at construction because of a genuine ordering knot: the persistent-config loader finds .lattice/config.toml by resolving a project root, so the resolver has to exist before the config that configures it has been read. It is built with the defaults and re-pointed here — which is also why this drops the cache.

Source

fn invalidate(&self)

Drop every cached answer — :project-refresh, after a git init mid-session. The cache is an optimisation and never a source of truth, so this changes latency and nothing else.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§