Skip to main content

Module ops

Module ops 

Source
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 Config and returns a report value. Nothing is written to stdout / stderr; the CLI renders the report.
  • Errors are PkgError. Per-dependency fetch failures are wrapped in PkgError::Fetch so 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 Project are resolved by std::fs against the cwd like any other path.

§Operation summary

fnreadswritesnetwork
installmanifestlockfile, <pkg_dir>/cache, <pkg_dir>/vendored or target_dir copiesyes (fetch)
addmanifest (optional)manifestno
updatemanifestmanifest (only --force tag bumps), then everything install writesyes (tag listing + fetch)
cleanlockfileremoves under <pkg_dir>/cacheno

Structs§

AddReport
Result of add.
AddSpec
What add should write into [deps.<name>].
InstallReport
Result of install.
InstalledPkg
One row of an InstallReport.
PatchOpts
Options for patch.
PatchReport
Result of patch.
UpdateOpts
Options for update.
UpdateReport
Result of update.

Enums§

AddOutcome
Whether add inserted a new entry or replaced an existing one.
CleanReport
Result of clean.
Placement
Where a dependency’s package root was placed by install.
UpdateOutcome
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, and PkgError::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) the patch_dir of one dep from the commit its pin resolves to, and record that commit as patch_base in the lockfile.
update
Refresh deps and bump tag pins as appropriate, then re-install.