Skip to main content

Backend

Trait Backend 

Source
pub trait Backend: Send + Sync {
Show 16 methods // Required methods fn id(&self) -> &str; fn default_sources(&self) -> Vec<Source>; fn probe_url(&self, ctx: &Ctx, source: &Source) -> Option<String>; fn list_remote_versions<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 Ctx, ) -> Pin<Box<dyn Future<Output = Result<Vec<VersionInfo>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn install<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, ctx: &'life1 InstallCtx<'life2>, tv: &'life3 ToolVersion, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait; fn bin_paths(&self, ctx: &Ctx, tv: &ToolVersion) -> Result<Vec<PathBuf>>; fn bin_names(&self, ctx: &Ctx, tv: &ToolVersion) -> Result<Vec<String>>; // Provided methods fn aliases(&self) -> &[&str] { ... } fn resolve_version<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ctx: &'life1 Ctx, req: &'life2 ToolRequest, ) -> Pin<Box<dyn Future<Output = Result<ToolVersion>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn ensure_post_install(&self, _ctx: &Ctx, _tv: &ToolVersion) -> Result<()> { ... } fn uninstall<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ctx: &'life1 Ctx, tv: &'life2 ToolVersion, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn list_installed(&self, ctx: &Ctx) -> Result<Vec<String>> { ... } fn exec_env( &self, _ctx: &Ctx, _tv: &ToolVersion, ) -> Result<BTreeMap<String, String>> { ... } fn dynamic_install_identity( &self, _ctx: &Ctx, _tv: &ToolVersion, ) -> Result<Option<InstallIdentity>> { ... } fn validate_dynamic_install( &self, _ctx: &Ctx, _tv: &ToolVersion, _install_root: &Path, _identity: &InstallIdentity, ) -> Result<bool> { ... } fn idiomatic_files(&self) -> &[&str] { ... }
}
Expand description

The uniform interface for every SDK. Archive-based backends run the shared pipeline in install; delegate backends (rustup/corepack) shell out.

Required Methods§

Source

fn id(&self) -> &str

Canonical id, e.g. “node”, “go”, “python”.

Source

fn default_sources(&self) -> Vec<Source>

The default source list for this backend (official + mirrors).

Source

fn probe_url(&self, ctx: &Ctx, source: &Source) -> Option<String>

A representative small URL used to speed-probe a source. Given a source’s download base, return a URL to fetch for measuring throughput.

Source

fn list_remote_versions<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 Ctx, ) -> Pin<Box<dyn Future<Output = Result<Vec<VersionInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List installable versions (typically parsed from a remote index).

Source

fn install<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, ctx: &'life1 InstallCtx<'life2>, tv: &'life3 ToolVersion, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Install a concrete version.

Source

fn bin_paths(&self, ctx: &Ctx, tv: &ToolVersion) -> Result<Vec<PathBuf>>

Directories to add to PATH for an installed version (its bin/ dirs).

Source

fn bin_names(&self, ctx: &Ctx, tv: &ToolVersion) -> Result<Vec<String>>

Executable names this version exposes (used to generate shims).

Provided Methods§

Source

fn aliases(&self) -> &[&str]

Alternate names accepted on the CLI (e.g. “nodejs” -> “node”).

Source

fn resolve_version<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ctx: &'life1 Ctx, req: &'life2 ToolRequest, ) -> Pin<Box<dyn Future<Output = Result<ToolVersion>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Resolve a request (e.g. 20, lts) to a concrete version.

Source

fn ensure_post_install(&self, _ctx: &Ctx, _tv: &ToolVersion) -> Result<()>

Apply idempotent post-install actions to an already installed version.

Source

fn uninstall<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ctx: &'life1 Ctx, tv: &'life2 ToolVersion, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Remove an installed version. Default removes the install dir.

Source

fn list_installed(&self, ctx: &Ctx) -> Result<Vec<String>>

List locally installed versions (dirs with a complete marker).

Source

fn exec_env( &self, _ctx: &Ctx, _tv: &ToolVersion, ) -> Result<BTreeMap<String, String>>

Environment variables to export when this version is active (e.g. GOROOT, JAVA_HOME).

Source

fn dynamic_install_identity( &self, _ctx: &Ctx, _tv: &ToolVersion, ) -> Result<Option<InstallIdentity>>

Exact identity selected for a dynamic install. None retains inventory discovery for backends whose artifact identity is learned at install.

Source

fn validate_dynamic_install( &self, _ctx: &Ctx, _tv: &ToolVersion, _install_root: &Path, _identity: &InstallIdentity, ) -> Result<bool>

Validate provider-specific evidence after shared inventory validation.

Source

fn idiomatic_files(&self) -> &[&str]

Idiomatic version files this backend understands (e.g. .nvmrc).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§