Crate cargo_manifest

Source
Expand description

§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.

Structs§

Badge
Badges
DependencyDetail
Filesystem
A AbstractFilesystem implementation that reads from the actual filesystem within the given root path.
InheritedDependencyDetail
When a dependency is defined as { workspace = true }, and workspace data hasn’t been applied yet.
Maintenance
Manifest
The top-level Cargo.toml structure
Package
You can replace Metadata type with your own to parse into something more useful than a generic toml Value
Product
Cargo uses the term “target” for both “target platform” and “build target” (the thing to build), which makes it ambigous. Here Cargo’s bin/lib target is renamed to product.
Profile
Profiles
Target
Workspace
WorkspacePackage
The workspace.package table is where you define keys that can be inherited by members of a workspace. These keys can be inherited by defining them in the member package with {key}.workspace = true.

Enums§

Dependency
Edition
Error
MaintenanceStatus
MaybeInherited
Used as a wrapper for properties that may be inherited by workspace-level settings. It currently does not support more complex interactions (e.g. specifying part of the property in the local manifest while inheriting another part of it from the workspace manifest, as it happens for dependency features).
Publish
Resolver
StringOrBool
StripSetting
Value
Representation of a TOML value.

Traits§

AbstractFilesystem
A trait for abstracting over filesystem operations.

Type Aliases§

DepsSet
FeatureSet
PatchSet
TargetDepsSet