Expand description
Library API for the cargo-feature-manifest and cargo-fm tools.
The command-line interface and metadata format are the primary supported
surfaces before 1.0. The library API is available for integrations and
tests, but may still change while the crate is pre-1.0.
The crate reads Cargo feature definitions, attaches maintainer-authored metadata, validates common documentation and policy mistakes, and renders the result for docs or automation.
Typical entry points:
load_workspaceto discover workspace packages viacargo metadata.load_manifestto read a singleCargo.toml.validateto lint feature metadata.render_markdownto generate documentation output.render_mermaidto visualize feature relationships.render_jsonto emit a versioned machine-readable schema.sync_manifestto scaffold or normalize metadata tables.preview_sync_manifestto inspect sync rewrites before writing.
Structs§
- Dependency
Info - Dependency details relevant to feature validation.
- Feature
- A single Cargo feature and its associated metadata.
- Feature
Group - A logical grouping of related features.
- Feature
Manifest - A normalized view of Cargo features plus structured feature metadata.
- Feature
Metadata - Additional author-provided metadata for a feature.
- Injection
Markers - Marker pair used for injecting generated content into an existing file.
- Injection
Report - Result of a marker-based document injection.
- Issue
- A single validation finding produced by
validate. - LintDoc
- Documentation for a supported lint code.
- Manifest
Source Map - Lightweight source map for locating feature-manifest diagnostics in TOML.
- Marker
Report - Marker discovery details for a generated documentation region.
- Source
Span - Best-effort source location inside a manifest file.
- Sync
Options - Options controlling how
sync_manifestrewrites metadata. - Sync
Preview - Non-writing result from a manifest synchronization preview.
- Sync
Report - Summary of a manifest synchronization pass.
- Validate
Options - Configuration applied during validation.
- Validation
Report - Aggregated output from a validation run.
- Workspace
Manifest - A workspace-aware view of one or more Cargo packages selected for analysis.
Enums§
- Feature
Ref - A typed reference inside a feature definition.
- Lint
Level - Severity override policy for a specific lint code.
- Lint
Preset - A named lint policy intended to make adoption and strict CI setup easier.
- Metadata
Layout - Layout used for feature metadata inside
package.metadata. - Package
Selection - Selects which package set to load from a Cargo workspace.
- Severity
- Severity level attached to a validation issue.
Constants§
- FEATURE_
DOCS_ METADATA_ TABLE - Legacy compatibility table name under
[package.metadata]. - FEATURE_
MANIFEST_ METADATA_ TABLE - Canonical table name under
[package.metadata]. - KNOWN_
LINT_ CODES - Lint codes recognized by validation and CLI override parsing.
Functions§
- ensure_
injection_ markers - Ensures a document contains a marker pair, appending it when absent.
- inject_
between_ markers - Replaces the region between two markers, preserving the markers themselves.
- injected_
region_ matches - Returns
truewhen the region between markers already matches the expected contents. - inspect_
markers - Returns marker status for a document without changing it.
- known_
lint_ codes - Returns the known lint codes in stable order.
- lint_
docs - Returns generated documentation for all known lint codes.
- load_
manifest - Loads and parses a manifest from disk.
- load_
workspace - Loads a selected package set from Cargo metadata and parses each manifest.
- output_
matches - Returns
truewhen a generated file already matches the expected contents. - parse_
lint_ override - Parses a lint override string like
missing-description=warn. - parse_
manifest_ str - Parses a manifest from a TOML string and normalizes its feature metadata.
- preview_
sync_ manifest - Computes the synchronization result and rewritten TOML without writing it.
- render_
explain - Renders a human-readable explanation for a named feature.
- render_
json - Renders the selected workspace/package metadata as pretty-printed JSON.
- render_
markdown - Renders the selected packages as Markdown.
- render_
mermaid - Renders selected packages as a Mermaid graph.
- render_
sync_ diff - Renders a compact unified diff for a manifest preview.
- resolve_
manifest_ path - Resolves a manifest path from either a
Cargo.tomlfile or a crate directory. When omitted, the current directory is used. - sync_
manifest - Adds missing metadata scaffolding to a manifest in place.
- validate
- Validates a manifest for missing docs, stale metadata, and risky defaults.
- validate_
with_ options - Validates a manifest with CLI lint overrides applied on top of manifest config.
- write_
output - Writes generated content to a file, ensuring a trailing newline.