26 releases

new 0.21.0 Dec 5, 2024
0.20.5 Sep 24, 2024
0.20.4 Jul 19, 2024
0.19.2 Mar 4, 2024
0.3.0 Jun 16, 2018

#23 in Parser implementations

Download history 123953/week @ 2024-08-19 135470/week @ 2024-08-26 138316/week @ 2024-09-02 136722/week @ 2024-09-09 123263/week @ 2024-09-16 133094/week @ 2024-09-23 138733/week @ 2024-09-30 129386/week @ 2024-10-07 144358/week @ 2024-10-14 131354/week @ 2024-10-21 134025/week @ 2024-10-28 135356/week @ 2024-11-04 148669/week @ 2024-11-11 152274/week @ 2024-11-18 156700/week @ 2024-11-25 161223/week @ 2024-12-02

627,698 downloads per month
Used in 490 crates (189 directly)

Apache-2.0 OR MIT

120KB
2K SLoC

Deserialize Cargo.toml

tom replacement

This is a definition of fields in Cargo.toml files for serde. It allows reading of Cargo.toml data, and serializing it using TOML or other formats. It's used by the lib.rs site to extract information about crates.

This crate is more than just schema definition. It supports post-processing of the data to emulate Cargo's workspace inheritance and autobins features. It supports files on disk as well as other non-disk data sources.

To get started, see Manifest::from_slice. If you need to get information about Cargo projects local to devs' machines, also consider cargo_metadata.

Features

  • Allows parsing Cargo.toml independently of Cargo. It can read manifests that use nightly features, without requiring a nightly Cargo version. Unlike cargo metadata, this is a standalone self-contained implementation, and it doesn't run any external commands.

  • It is safe to use with untrusted code. It is just a parser. It won't run any build commands nor apply any .cargo/config.toml files.

  • It supports Cargo workspaces and inheritance of fields.

  • It supports abstracting the file system, so parsing of Cargo.toml can auto-detect files parsed from .crate tarballs, bare git repositories, and other data sources, without having to extract the files to disk first.

  • It has optional helper functions for interpreting the [features] section.

There will be updates

Cargo regularly adds new features to Cargo.toml. Keep this crate up-to-date to correctly parse them all — use dependabot or renovate.

Dependencies

~0.5–1MB
~24K SLoC