api-parity-rs
Rust plugin for api-parity. Provides:
- Attribute macros (
#[parity],#[parity_impl]) for annotating a Rust crate as a port of some upstream API. - A reference-mode walker (behind the
walkerCargo feature) that inspects another Rust crate's public surface viacargo +nightly rustdoc. - A CLI bin (
api-parity-rs) that drives both modes and emits akind = port/kind = referenceenvelope per SCHEMA.md.
The workspace contains two crates: api-parity-rs (lib + bin in one crate, gated by features) and api-parity-rs-macros (the proc-macros, separated because proc-macro = true crates can't ship anything else).
Install
# CLI only — port-mode driver (cargo run --bin api-parity-dump under the hood):
# With reference-mode walker (rustdoc-json + public-api). Requires nightly Rust at runtime:
For library use (annotating a target crate), add it as a Cargo dep — see below.
Annotating a target crate
Add the lib as a dep with the default CLI feature off; keep serde so the dump helper is available:
[]
= { = "0.0.2", = false, = ["serde"] }
[[]]
= "api-parity-dump"
= "src/bin/api-parity-dump.rs"
Annotate impls and free functions:
use ;
Add a 3-line bin that serializes the registered entries:
// src/bin/api-parity-dump.rs
A leading . in a child path is rewritten to <parent>.<child> at macro-expansion time. Status::Unimplemented requires a comment.
CLI usage
kind:portorreference.--mode: defaults toannotationforport,walkerforreference.<crate-path>: directory containing the targetCargo.toml.-o: output file, or-for stdout (default).
Drives cargo run --bin api-parity-dump --manifest-path <target>/Cargo.toml and forwards stdout. The target crate must define src/bin/api-parity-dump.rs (see Annotating a target crate above).
Shells out to cargo +nightly rustdoc --output-format json (via rustdoc-json) and parses the result with public-api. Requires --features walker at install time and a nightly toolchain at runtime.
Cargo features
| Feature | Default | What it adds |
|---|---|---|
cli |
yes | The api-parity-rs CLI bin (depends on clap). |
serde |
dump_to_writer JSON helper (depends on serde + serde_json). |
|
walker |
Reference-mode walker (depends on public-api + rustdoc-json, implies cli + serde). |
Target crates that only annotate set default-features = false, features = ["serde"] to avoid the CLI / clap compile cost.
Pipelines
# Python reference ↔ Rust port (the canonical case):
# Rust ↔ Rust (no annotations needed on either side):