Skip to main content

Crate cargo_ratchet

Crate cargo_ratchet 

Source
Expand description

Prevent resolved versions in Cargo.lock from regressing below a committed baseline that only ratchets up.

The binary (cargo ratchet) is a thin wrapper over this library. Embed the library when you want the same check inside another tool:

  • compute_violations is the pure comparison: two parsed lockfiles in, violations out.
  • check_and_advance adds the file orchestration: compare, and copy the lockfile over the baseline on a passing check.
  • check_fail_on_change is the read-only CI variant: pass only when the baseline is byte-identical to the lockfile.

Structs§

RatchetPaths
Locations of the lockfile and its ratchet baseline.

Enums§

Violation
A place where resolved Cargo.lock state regressed below the baseline.

Functions§

check_and_advance
Check the lockfile against the ratchet baseline and, when the check passes (an empty return), copy the lockfile over the baseline so the floor ratchets up. A missing baseline is not a violation: the first run bootstraps it.
check_fail_on_change
Read-only check for CI: returns whether the baseline is byte-identical to the lockfile (a missing baseline is a mismatch). Byte-identical files trivially contain no regressions, so nothing is parsed; on a throwaway checkout an advance would be discarded, so any mismatch means someone needs to run cargo ratchet locally and commit the result.
compute_violations
Compare current against baseline and report every regression of resolved versions.