Rust library

mmz ships as a library crate as well as a binary; the binary is a thin wrapper over it.

Why a library

The binary is argument parsing, logging setup, and a mapping from library errors to exit codes. Everything else — manifest loading, glob resolution, hashing, probe execution, record I/O — is the library, so a tool that wants memoization as a step rather than as a prefix does not have to shell out to get it.

mmz = "0.13.0"

Memoize one invocation

let argv = vec!["cargo".to_owned(), "test".to_owned()];
std::process::exit(mmz::run(&argv, std::path::Path::new("."))?.into());

mmz::run does what the prefix does: find the nearest manifest above cwd, match argv to a rule, resolve and hash its inputs, and either return the recorded exit code without running anything or run the command and record the result on success.

The rest of the surface

ItemWhat it is for
mmz::runMemoize one invocation; returns its exit code.
mmz::statusThe freshness report --status renders, as data.
mmz::pruneSweep records whose rule no longer exists.
mmz::freshnessThe --is-fresh verdicts, one per rule or expansion.
mmz::ManifestLoad and validate a manifest without running anything.
mmz::clockThe one “now” a run stamps and renders; MMZ_NOW pins it.
mmz::error::ErrorThe error enum every entry point returns.
Errors are a thiserror enum, not opaque strings, so a caller can match on the case it cares about — a missing manifest, a probe failure, a strict refusal — rather than parsing a message. The binary’s own exit-code mapping is exactly such a match; see the exit codes.

What the library does not do

The same boundaries the CLI has, for the same reasons: no orchestration, no output replay, no dependency tracing, no remote cache. mmz::run runs one command and answers one question about it.

Full API documentation is on docs.rs.