#cargo-metadata #cargo-toml #serde #metadata

cargo-manifest

Helper crate to parse and manipulate manifests - Cargo.toml files

36 releases (18 breaking)

0.19.1 Jan 16, 2025
0.18.1 Jan 13, 2025
0.17.0 Nov 28, 2024
0.15.0 Jun 29, 2024
0.2.1 Nov 29, 2020

#50 in Parser implementations

Download history 22710/week @ 2025-01-10 18384/week @ 2025-01-17 17412/week @ 2025-01-24 19784/week @ 2025-01-31 20395/week @ 2025-02-07 17632/week @ 2025-02-14 20261/week @ 2025-02-21 20113/week @ 2025-02-28 20497/week @ 2025-03-07 25141/week @ 2025-03-14 22840/week @ 2025-03-21 23092/week @ 2025-03-28 26240/week @ 2025-04-04 23059/week @ 2025-04-11 25299/week @ 2025-04-18 22319/week @ 2025-04-25

101,200 downloads per month
Used in 160 crates (20 directly)

Apache-2.0 OR MIT

57KB
1K SLoC

cargo-manifest

serde definitions to read and write Cargo.toml files.

Description

This Rust crate contains various structs and enums to represent the contents of a Cargo.toml file. These definitions can be used with serde and the toml crate to read and write Cargo.toml manifest files.

This crate also to some degree supports post-processing of the data to emulate Cargo's workspace inheritance and autobins features. This is used for example by crates.io to extract whether a crate contains a library or executable binaries.

[!NOTE] The cargo team regularly adds new features to the Cargo.toml file definition. This crate aims to keep up-to-date with these changes. You should keep this crate up-to-date to correctly parse all fields in modern Cargo.toml files.

Installation

cargo add cargo-manifest

Usage

use cargo_manifest::Manifest;

let manifest = Manifest::from_path("Cargo.toml").unwrap();

see docs.rs for more information.

Users

Alternatives

This crate is a fork of the cargo_toml project. There are only some minor differences between these projects at this point, you will need to evaluate which one fits your needs better.

There is also cargo-util-schemas now, which is maintained by the cargo team themselves. This crate was extracted from the cargo codebase and is used inside the cargo binary itself. It is kept up-to-date with the latest changes to the Cargo.toml file format, but is currently lacking some of the post-processing features that cargo-manifest provides.

License

This project is licensed under either of

at your option.

Dependencies

~2.4–3MB
~72K SLoC