Switch on and off
Every way to switch, in one place:
| What | On | Off |
|---|---|---|
| A TS/JS or Python unit, in place | rust-anything enable <crate>: one marked block in each original file rebinds the ported functions to the Rust module, so every caller gets Rust and no import changes. It refuses while a recorded case differs (--force skips that check); go runs it only after diff and gate pass |
rust-anything disable <crate>: removes exactly the lines enable added, so the files are byte for byte what they were |
| That unit, for one run | (on by default once enabled) | RUST_ANYTHING_UNIT_<NAME>=original (<NAME> is the crate name without -rs, upper case: RUST_ANYTHING_UNIT_DEDUPE), or RUST_ANYTHING_MODE=old for every unit |
| A shadow module (any language) | Import it where the app imported the original; RUST_ANYTHING_MODE=new runs only Rust |
RUST_ANYTHING_MODE=old; the default, shadow, returns the original's result and compares Rust |
A unit wired into a front door (app wire) |
Wired units answer in Rust | RUST_ANYTHING_UNIT_<NAME>=original sends that unit's commands to the original |
An installed package (package) |
The platform's binary | RUST_ANYTHING_MODE=old runs the original it depends on |
The enable block names the crate by a path relative to the source file, so it holds no path
of your machine, and it falls back to the original when the module does not load (with
RUST_ANYTHING_MODE=new that is an error instead). record, diff, bench and fuzz set the
unit's switch to original for the original's side, so an enabled unit is still measured
against the original. Other languages switch through the shadow module.
One build cache
Ports and bridges build into one cargo target folder: CARGO_TARGET_DIR when it is set, else
rust-anything/target in your cache folder (~/Library/Caches on macOS, $XDG_CACHE_HOME or
~/.cache on Linux, %LOCALAPPDATA% on Windows). napi-rs, PyO3, serde and the rest compile once
for every crate instead of once per crate. rust-anything clean removes the folder
(--dry-run prints its size; a folder named by CARGO_TARGET_DIR needs --force, since other
projects may build there).
Cargo names a crate's library after its package name alone, so two crates with one name would
replace each other's library in a shared folder (see docs/pitfalls.md). Each package name
belongs to one crate folder there (owners.json, written under a lock); another crate with the
same name builds in its own target/ as before, and gets the name back once the first folder is
gone. Each crate's libraries are copied to its own target/release, where every loader reads
them. Front doors (rust/app) keep their own target/, since every app's binary would have the
same name.