Skip to main content

Plugin

Trait Plugin 

Source
pub trait Plugin {
    // Required methods
    fn manifest(&self) -> &PluginManifest;
    fn available_versions(
        &self,
        args: &[String],
    ) -> PluginResult<Vec<AvailableVersion>>;
    fn install_plan(&self, version: &str) -> PluginResult<InstallPlan>;
    fn env_keys(&self, runtime: &InstalledRuntime) -> PluginResult<Vec<EnvKey>>;
    fn parse_legacy_file(
        &self,
        file_name: &str,
        file_path: &Path,
        content: &str,
        installed_versions: &[String],
        strategy: &str,
    ) -> PluginResult<Option<String>>;

    // Provided methods
    fn post_install(&self, _runtime: &InstalledRuntime) -> PluginResult<()> { ... }
    fn pre_use(
        &self,
        _requested_version: &str,
        _scope: &str,
        _cwd: &Path,
        _previous_version: Option<&str>,
        _installed: &[InstalledRuntime],
    ) -> PluginResult<Option<String>> { ... }
    fn pre_uninstall(&self, _runtime: &InstalledRuntime) -> PluginResult<()> { ... }
}
Expand description

Common runtime interface used by the application layer.

Required Methods§

Source

fn manifest(&self) -> &PluginManifest

Returns the immutable plugin manifest.

Source

fn available_versions( &self, args: &[String], ) -> PluginResult<Vec<AvailableVersion>>

Lists versions that the plugin can install.

Source

fn install_plan(&self, version: &str) -> PluginResult<InstallPlan>

Builds an install plan for the requested version.

Source

fn env_keys(&self, runtime: &InstalledRuntime) -> PluginResult<Vec<EnvKey>>

Returns environment keys that should be exported for the installed version.

Source

fn parse_legacy_file( &self, file_name: &str, file_path: &Path, content: &str, installed_versions: &[String], strategy: &str, ) -> PluginResult<Option<String>>

Attempts to map a legacy file content to a version.

Provided Methods§

Source

fn post_install(&self, _runtime: &InstalledRuntime) -> PluginResult<()>

Runs optional post-install logic after artifacts are materialized.

Source

fn pre_use( &self, _requested_version: &str, _scope: &str, _cwd: &Path, _previous_version: Option<&str>, _installed: &[InstalledRuntime], ) -> PluginResult<Option<String>>

Allows a plugin to map the requested version before activation.

Source

fn pre_uninstall(&self, _runtime: &InstalledRuntime) -> PluginResult<()>

Runs optional pre-uninstall logic before a version is removed.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§