Crate cargo_toml

Source
Expand description

This crate defines structs that can be deserialized with Serde to load and inspect Cargo.toml metadata.

See Manifest::from_path. Note that Cargo.toml files are not self-contained. Correct interpretation of the manifest requires other files on disk:

  • List of files in order to auto-discover binaries, examples, benchmarks, and tests.
  • Potentially a Manifest from one of parent directories, that acts as a workspace root for inheritance of shared workspace information.

Because of this filesystem-dependence, loading Cargo.toml from a string is an advanced operation. The crate has methods for processing this information, but if you don’t already have a full crate on disk, you will need to write some glue code to obtain it. See Manifest::complete_from_path_and_workspace.

Structs§

Badge
In badges section of Cargo.toml
Badges
[badges] section of Cargo.toml, deprecated by crates-io except maintenance.
DependencyDetail
When definition of a dependency is more than just a version string.
Filesystem
AbstractFilesystem implementation for real files.
InheritedDependencyDetail
When a dependency is defined as { workspace = true }, and workspace data hasn’t been applied yet.
Lint
Lint definition.
Maintenance
A Badges field with MaintenanceStatus.
Manifest
The top-level Cargo.toml structure. This is the main type in this library.
Package
The [package] section of the Manifest. This is where crate properties are.
PackageTemplate
Workspace can predefine properties that can be inherited via { workspace = true } in its member packages.
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
Compilation/optimization settings for a workspace
Profiles
Build-in an custom build/optimization settings
Target
Dependencies that are platform-specific or enabled through custom cfg().
Workspace
A manifest can contain both a package and workspace-wide properties

Enums§

DebugSetting
Verbosity of debug info in a Profile
Dependency
Dependency definition. Note that this struct doesn’t carry it’s key/name, which you need to read from its section.
Edition
Edition setting, which opts in to new Rust/Cargo behaviors.
Error
In this crate’s Results.
Inheritable
Placeholder for a property that may be missing from its package, and needs to be copied from a Workspace.
LintLevel
Lint level.
LtoSetting
Handling of LTO in a build profile
MaintenanceStatus
Mainly used to deprecate crates.
OptionalFile
A way specify or disable README or build.rs.
Publish
Forbids or selects custom registry
Resolver
The feature resolver version.
StripSetting
Handling of debug symbols in a build profile
Value
Representation of a TOML value.

Traits§

AbstractFilesystem
This crate supports reading Cargo.toml not only from a real directory, but also directly from other sources, like tarballs or bare git repos (BYO directory reader).

Type Aliases§

DepsSet
Dependencies. The keys in this map are not always crate names, this can be overriden by the package field, and there may be multiple copies of the same crate. Optional dependencies may create implicit features, see the [features] module for dealing with this.
FeatureSet
The [features] section. This set may be incomplete!
LintGroups
Lint groups such as [lints.rust].
LintSet
A set of lints.
PatchSet
Locally replace dependencies
TargetDepsSet
Config target (see parse_cfg crate) + deps for the target.