Skip to main content

PackageHandler

Trait PackageHandler 

Source
pub trait PackageHandler {
    // Required methods
    fn install(&self, source: &str, local: bool) -> Result<(), String>;
    fn remove(&self, source: &str, local: bool) -> Result<bool, String>;
    fn list(&self) -> Result<Vec<ListedPackage>, String>;
    fn is_project_trusted(&self) -> bool;
    fn refresh_models(&self) -> Result<(), String>;
    fn update_extensions(&self, source: Option<&str>) -> Result<(), String>;
    fn update_self(&self, force: bool) -> Result<bool, String>;

    // Provided methods
    fn set_offline(&self, _offline: bool) { ... }
    fn set_project_trust_override(&self, _trust_override: Option<bool>) { ... }
}
Expand description

Side-effect surface injected by the caller.

Each method maps to one subcommand operation. Implementations may run real subprocesses (core::package_manager::PackageManager) or fake the work in tests. Strings returned by Err are surfaced verbatim prefixed with Error: .

Required Methods§

Source

fn install(&self, source: &str, local: bool) -> Result<(), String>

Install source in the requested scope.

§Errors

Implementation-defined; the error string is shown verbatim.

Source

fn remove(&self, source: &str, local: bool) -> Result<bool, String>

Remove source; returns whether anything was removed.

§Errors

Implementation-defined.

Source

fn list(&self) -> Result<Vec<ListedPackage>, String>

List configured packages split by scope.

§Errors

Implementation-defined.

Source

fn is_project_trusted(&self) -> bool

Whether the project is currently trusted (for the local-write gate).

Source

fn refresh_models(&self) -> Result<(), String>

Refresh model catalogs (update --models).

§Errors

Implementation-defined.

Source

fn update_extensions(&self, source: Option<&str>) -> Result<(), String>

Update installed extensions, optionally filtered by source.

§Errors

Implementation-defined.

Source

fn update_self(&self, force: bool) -> Result<bool, String>

Self-update pi; force reinstalls even when on the latest version.

Returns Ok(false) when the engine reports the current install is already latest and no reinstall was requested.

§Errors

Implementation-defined.

Provided Methods§

Source

fn set_offline(&self, _offline: bool)

Apply invocation-scoped offline mode before package-command dispatch.

Source

fn set_project_trust_override(&self, _trust_override: Option<bool>)

Supply the invocation-scoped project trust override before preflight.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§