Skip to main content

Module config

Module config 

Source
Expand description

Single entry value for the operations in crate::ops.

Config bundles where things live (Project) with what the manifest says (ManifestSource). Every operation takes a &Config, so an embedding application has exactly one type to build, and every knob that mlua-pkg.toml / the CLI flags can express is reachable from Rust without touching the filesystem first:

knobcarried by
--mlua-pkgs-dir / MLUA_PKG_DIRPkgDir inside Project
manifest / lockfile locationProject
[package] + [deps.<name>] (the whole mlua-pkg.toml)ManifestSource::Value holding a Manifest
add argumentsAddSpec
update flagsUpdateOpts

§File vs value

ManifestSource::File is what the CLI uses: the manifest is read from project.manifest_path() and, for add / update, written back there.

ManifestSource::Value is the SDK form: the caller hands over a Manifest it built (or parsed with Manifest::from_toml_str). Nothing is written to manifest_path(); operations that would change the manifest return the new one in their report instead (AddReport::manifest, UpdateReport::manifest). The lockfile and the cache / vendored directories are still written to the paths in Project in both modes — they are outputs, not inputs.

use mlua_pkg::{manifest::{Dep, Manifest, Package}, ops, Config, PkgDir, Project};
use std::collections::HashMap;

let root = "/srv/app";
let project = Project::in_dir(root, PkgDir::default_in(root));

// Build the manifest in memory instead of writing mlua-pkg.toml.
let mut deps = HashMap::new();
deps.insert("lshape".to_string(), Dep {
    git: "https://github.com/ynishi/lshape".into(),
    tag: Some("v0.1".into()),
    rev: None, branch: None, entry: None, target_dir: None, patch_dir: None, patch_drift: None,
});
let manifest = Manifest {
    package: Package { name: "app".into(), version: "0.1.0".into(), entry: None },
    deps,
};

let cfg = Config::with_manifest(project, manifest);
let report = ops::install(&cfg)?;
assert_eq!(report.direct, 1);

Structs§

Config
Everything an operation needs: paths plus the manifest.

Enums§

ManifestSource
Where ops takes the manifest from.