{"id":13539593,"url":"https://github.com/cargo-public-api/cargo-public-api","last_synced_at":"2025-05-14T08:06:42.310Z","repository":{"id":37564930,"uuid":"446043060","full_name":"cargo-public-api/cargo-public-api","owner":"cargo-public-api","description":"List and diff the public API of Rust library crates between releases and commits. Detect breaking API changes and semver violations via CI or a CLI.","archived":false,"fork":false,"pushed_at":"2025-05-12T16:58:53.000Z","size":4620,"stargazers_count":473,"open_issues_count":5,"forks_count":32,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-12T22:02:44.892Z","etag":null,"topics":["api","cargo","cargo-plugin","cargo-subcommand","diff","rust","rustdoc-json","semver"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/cargo-public-api","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cargo-public-api.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"docs/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["Enselic"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2022-01-09T09:20:48.000Z","updated_at":"2025-05-09T04:34:52.000Z","dependencies_parsed_at":"2023-10-16T17:09:50.846Z","dependency_job_id":"412a762c-7baa-4b5f-92ca-4d5feab558b5","html_url":"https://github.com/cargo-public-api/cargo-public-api","commit_stats":{"total_commits":1274,"total_committers":26,"mean_commits":49.0,"dds":0.2543171114599686,"last_synced_commit":"d710c4014eac8a2cc6b808b26dec40389c0aff8b"},"previous_names":["cargo-public-api/cargo-public-api"],"tags_count":202,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cargo-public-api%2Fcargo-public-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cargo-public-api%2Fcargo-public-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cargo-public-api%2Fcargo-public-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cargo-public-api%2Fcargo-public-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cargo-public-api","download_url":"https://codeload.github.com/cargo-public-api/cargo-public-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254101616,"owners_count":22014909,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","cargo","cargo-plugin","cargo-subcommand","diff","rust","rustdoc-json","semver"],"created_at":"2024-08-01T09:01:28.552Z","updated_at":"2025-05-14T08:06:37.293Z","avatar_url":"https://github.com/cargo-public-api.png","language":"Rust","funding_links":["https://github.com/sponsors/Enselic"],"categories":["Rust"],"sub_categories":[],"readme":"# cargo-public-api\n\nList and diff the public API of Rust library crates between releases and commits. Detect breaking API changes and semver violations via CI or a CLI. Relies on and automatically builds [rustdoc JSON](https://github.com/rust-lang/rust/issues/76578), for which a recent version of the Rust nightly toolchain must be installed.\n\n# Installation\n\nInstall the `cargo public-api` subcommand with a recent regular **stable** Rust toolchain:\n\n```sh\ncargo +stable install cargo-public-api --locked\n```\n\nEnsure **nightly-2025-03-24** or later is installed (does not need to be the active toolchain) so `cargo public-api` can build rustdoc JSON for you:\n\n```sh\nrustup install nightly --profile minimal\n```\n\n# Usage\n\n## List the Public API\n\nThis example lists the public API of the `regex` crate. First we clone the repo:\n\n```sh\ngit clone https://github.com/rust-lang/regex ; cd regex\n```\n\nNow we can list the public API of `regex` by running\n\n```sh\ncargo public-api\n```\n\nwhich will print the public API of `regex` with one line per public item in the API:\n\n\u003cimg src=\"docs/img/list-truncated.webp\" alt=\"colored output of listing a public api\"\u003e\n\n## Diff the Public API\n\n### … Against a Specific Published Version\n\nTo diff the public API of the `regex` crate in the **current directory** against  **published version 1.6.0** on [crates.io](https://crates.io/crates/regex/1.6.0):\n\n```sh\ncargo public-api diff 1.6.0\n```\n\n\u003cimg src=\"docs/img/diff-specific-published-version.webp\" alt=\"colored output of diffing a public api\"\u003e\n\n\n### … Against the Latest Published Version\n\n```sh\ncargo public-api diff latest\n```\n\n### … Between Git Commits\n\n```sh\ncargo public-api diff ref1..ref2\n```\n\n### … as a CI Check\n\n\u003c!-- Keep this section in sync with ./public-api/README.md#public-api-surface-test-in-ci --\u003e\n\nWith a regular `cargo test` that you run in CI you will be able to\n* prevent accidental changes to your public API\n* review the public API diff of deliberate changes\n\nFirst add the latest versions of the recommended libraries to your `[dev-dependencies]`:\n\n```sh\ncargo add --dev \\\n    rustup-toolchain \\\n    rustdoc-json \\\n    public-api \\\n    insta\n```\n\nThen add the following test to your project. As the author of the below test code, I hereby associate it with [CC0](https://creativecommons.org/publicdomain/zero/1.0/) and to the extent possible under law waive all copyright and related or neighboring rights to it:\n\n```rust\n#[test]\nfn public_api() {\n    // Install a compatible nightly toolchain if it is missing\n    rustup_toolchain::install(public_api::MINIMUM_NIGHTLY_RUST_VERSION).unwrap();\n\n    // Build rustdoc JSON\n    let rustdoc_json = rustdoc_json::Builder::default()\n        .toolchain(public_api::MINIMUM_NIGHTLY_RUST_VERSION)\n        .build()\n        .unwrap();\n\n    // Derive the public API from the rustdoc JSON\n    let public_api = public_api::Builder::from_rustdoc_json(rustdoc_json)\n        .build()\n        .unwrap();\n\n    // Assert that the public API looks correct\n    insta::assert_snapshot!(public_api);\n}\n```\n\nBefore you run the test the first time you need to bless the current public API:\n\n```sh\nINSTA_UPDATE=always cargo test\n```\n\nThis creates a `tests/snapshots/\u003cmodule\u003e_public_api.snap` file in your project that you `git add` together with your other project files. Then a regular\n\n```sh\ncargo test\n```\n\nwill fail if your public API is accidentally or deliberately changed. Run\n\n```sh\nINSTA_UPDATE=always cargo test\n```\n\nagain to review and accept public API changes.\n\n## Less Noisy Output\n\nFor completeness, items belonging to _Blanket Implementations_, _Auto Trait Implementations_, and _Auto Derived Implementations_, such as\n\n * `impl\u003cT, U\u003e Into\u003cU\u003e for T where U: From\u003cT\u003e`\n * `impl Sync for ...`\n * `impl Debug for ...` / `#[derive(Debug)]`\n\nare included in the list of public items by default. Use\n\n * `--omit blanket-impls`\n * `--omit auto-trait-impls`\n * `--omit auto-derived-impls`\n\nrespectively to omit such items from the output to make it much less noisy:\n\n```sh\ncargo public-api --omit blanket-impls,auto-trait-impls,auto-derived-impls\n```\n\nFor convenience you can also use `-s` (`--simplified`) to achieve the same thing. This is a shorter form of the above command:\n\n```sh\ncargo public-api -sss\n```\n\n# Compatibility Matrix\n\n| Version          | Understands the rustdoc JSON output of  |\n| ---------------- | --------------------------------------- |\n| 0.47.x           | nightly-2025-03-24 —                    |\n| 0.46.x           | nightly-2025-03-16 — nightly-2025-03-23 |\n| 0.45.x           | nightly-2025-03-14 — nightly-2025-03-15 |\n| 0.43.x — 0.44.x  | nightly-2025-01-25 — nightly-2025-03-13 |\n| 0.40.x — 0.42.x  | nightly-2024-10-18 — nightly-2025-01-24 |\n| 0.39.x           | nightly-2024-10-13 — nightly-2024-10-17 |\n| 0.38.x           | nightly-2024-09-10 — nightly-2024-10-12 |\n| 0.37.x           | nightly-2024-07-05 — nightly-2024-09-09 |\n| 0.35.x — 0.36.x  | nightly-2024-06-07 — nightly-2024-07-04 |\n| 0.32.x — 0.34.x  | nightly-2023-08-25 — nightly-2024-06-06 |\n| 0.30.x — 0.31.x  | nightly-2023-05-24 — nightly-2023-08-24 |\n| earlier versions | see [here](https://github.com/cargo-public-api/cargo-public-api/blob/7056d59cd279610fc61cc9669be3840b0dd8273c/README.md#compatibility-matrix) |\n\n# Contributing\n\nSee [CONTRIBUTING.md](./docs/CONTRIBUTING.md).\n\n## Maintainers\n\n- [Enselic](https://github.com/Enselic)\n- [douweschulte](https://github.com/douweschulte)\n- [Emilgardis](https://github.com/Emilgardis)\n\n# Trademark Notice\n\n\"Rust\" and \"Cargo\" are trademarks of the Rust Foundation. This project is not affiliated with, endorsed by, or otherwise associated with the Rust Project or Rust Foundation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcargo-public-api%2Fcargo-public-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcargo-public-api%2Fcargo-public-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcargo-public-api%2Fcargo-public-api/lists"}