Skip to main content

PackageManager

Trait PackageManager 

Source
pub trait PackageManager: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn family(&self) -> Family;
    fn command(
        &self,
        ctx: &Context<'_>,
        verb: Verb,
        args: &[OsString],
    ) -> Result<CommandSpec, PluginError>;
}
Expand description

An implementation of one package manager backend, a purely synchronous interface: no async, no callbacks, no I/O – passing a Future across the dlopen boundary is the most fragile part of this approach. It should only do mapping; see the crate docs for the constraints.

A panic in any of these methods is caught by the export! shell – the #[unsafe(no_mangle)] wrapper catches it before it can cross extern "C", which would abort the host process. The host then sees a failed call, or the PANIC_MARKER name, and refuses to use the plugin; the panic message itself goes to stderr as usual.

Required Methods§

Source

fn name(&self) -> &str

Plugin name, e.g. "cargo". The host compares it against the name declared in the manifest and refuses to load on a mismatch.

Source

fn family(&self) -> Family

The ecosystem it belongs to.

Source

fn command( &self, ctx: &Context<'_>, verb: Verb, args: &[OsString], ) -> Result<CommandSpec, PluginError>

Translate “verb + arguments” into one concrete command. Return PluginError::UnsupportedVerb when a verb is not supported and do not improvise a near-equivalent command – the host degrades exec, the other verbs report the error as-is, and either is better than guessing.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§