Expand description
Package-manager operations: install / add / update / clean.
These are the same operations the mlua-pkg CLI exposes, as plain
library functions so an embedding application can drive them directly:
use mlua_pkg::{ops, Config, PkgDir, Project};
let project = Project::in_dir("/srv/app", PkgDir::default_in("/srv/app"));
let cfg = Config::new(project); // manifest read from mlua-pkg.toml
let report = ops::install(&cfg)?;
for pkg in &report.packages {
println!("{} @ {}", pkg.name, pkg.sha);
}To supply the manifest as a value instead of a file, build the
Config with Config::with_manifest; see crate::config for
how add / update behave in that mode.
§Contract
- Every function takes a
Configand returns a report value. Nothing is written to stdout / stderr; the CLI renders the report. - Errors are
PkgError. Per-dependency fetch failures are wrapped inPkgError::Fetchso the failing name is available structurally. - No function reads the process environment or the current working
directory to decide a path. Relative paths inside the
Projectare resolved bystd::fsagainst the cwd like any other path.
§Operation summary
Structs§
- AddReport
- Result of
add. - AddSpec
- What
addshould write into[deps.<name>]. - Install
Report - Result of
install. - Installed
Pkg - One row of an
InstallReport. - Patch
Opts - Options for
patch. - Patch
Report - Result of
patch. - Update
Opts - Options for
update. - Update
Report - Result of
update.
Enums§
- AddOutcome
- Whether
addinserted a new entry or replaced an existing one. - Clean
Report - Result of
clean. - Placement
- Where a dependency’s package root was placed by
install. - Update
Outcome - Per-dep decision made by
update.
Constants§
- MANIFEST_
REQUESTER - Requester label for a direct dependency (as opposed to a package name
for a transitive one). Appears in
InstalledPkg::requested_by,PkgError::Fetch, andPkgError::DepConflict.
Functions§
- add
- Insert (or replace) a
[deps.<name>]entry in the manifest. - clean
- Remove cached packages.
- install
- Fetch every dep in the manifest (and their transitive deps), place them, and write the lockfile.
- patch
- Create (or, with
force, rebuild) thepatch_dirof one dep from the commit its pin resolves to, and record that commit aspatch_basein the lockfile. - update
- Refresh deps and bump tag pins as appropriate, then re-install.