pub trait PackageManager: Send + Sync {
// Required methods
fn name(&self) -> &'static str;
fn is_available(&self) -> bool;
fn exists(
&self,
runner: &dyn Runner,
pkg: &str,
) -> Result<bool, PackageError>;
fn is_installed(
&self,
runner: &dyn Runner,
pkg: &str,
) -> Result<bool, PackageError>;
fn install(
&self,
runner: &dyn Runner,
packages: &[String],
) -> Result<(), PackageError>;
}Expand description
Abstraction over a system package manager.
Required Methods§
Sourcefn name(&self) -> &'static str
fn name(&self) -> &'static str
Stable lowercase identifier (e.g. "pacman", "apt").
This matches the field name in DepsGroup in the config schema.
Sourcefn is_available(&self) -> bool
fn is_available(&self) -> bool
Returns true when the manager’s binary is on PATH.
Sourcefn exists(&self, runner: &dyn Runner, pkg: &str) -> Result<bool, PackageError>
fn exists(&self, runner: &dyn Runner, pkg: &str) -> Result<bool, PackageError>
Returns true when pkg can be installed from the manager’s
configured sources (repositories, taps, buckets, registry), whether
or not it is installed. Used by krypt deps --check.
Sourcefn is_installed(
&self,
runner: &dyn Runner,
pkg: &str,
) -> Result<bool, PackageError>
fn is_installed( &self, runner: &dyn Runner, pkg: &str, ) -> Result<bool, PackageError>
Returns true when pkg is already installed.
Only errors on unexpected conditions — a clean “not installed” (exit 1
from a query command) is returned as Ok(false).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".