Crate cargo

source ·
Expand description

Cargo as a library

Cargo, the Rust package manager, is also provided as a library.

There are two places you can find API documentation of cargo-the-library,

Each of them targets on a slightly different audience.

For external tool developers

The documentation on https://docs.rs/cargo contains public-facing items in cargo-the-library. External tool developers may find it useful when trying to reuse existing building blocks from Cargo. However, using Cargo as a library has drawbacks, especially cargo-the-library is unstable, and there is no clear path to stabilize it soon at the time of writing. See The Cargo Book: External tools for more on this topic.

Cargo API documentation on docs.rs gets updates along with each Rust release. Its version always has a 0 major version to state it is unstable. The minor version is always +1 of rustc’s minor version (that is, cargo 0.66.0 corresponds to rustc 1.65).

For Cargo contributors

The documentation on https://doc.crates.io/contrib/apidoc/cargo contains all items in Cargo. Contributors of Cargo may find it useful as a reference of Cargo’s implementation details. It’s built with --document-private-items rustdoc flag, so you might expect to see some noise and strange items here. The Cargo team and contributors strive for jotting down every details from their brains in each issue and PR. However, something might just disappear in the air with no reason. This documentation can be seen as their extended minds, sharing designs and hacks behind both public and private interfaces.

If you are just diving into Cargo internals, Cargo Architecture Overview is the best material to get a broader context of how Cargo works under the hood. Things also worth a read are important concepts reside in source code, which Cargo developers have been crafting for a while, namely

This API documentation is published on each push of rust-lang/cargo master branch. In other words, it always reflects the latest doc comments in source code on master branch.

Contribute to Cargo documentations

The Cargo team always continues improving all external and internal documentations. If you spot anything could be better, don’t hesitate to discuss with the team on Zulip t-cargo stream, or submit an issue right on GitHub. There is also an issue label A-documenting-cargo-itself, which is generally for documenting user-facing The Cargo Book, but the Cargo team is welcome any form of enhancement for the Cargo Contributor Guide and this API documentation as well.

Re-exports

pub use crate::util::errors::AlreadyPrintedError;
pub use crate::util::errors::InternalError;
pub use crate::util::errors::VerboseError;
pub use crate::util::indented_lines;
pub use crate::util::CargoResult;
pub use crate::util::CliError;
pub use crate::util::CliResult;
pub use crate::util::Config;

Modules

Macros

Constants

Functions

Displays an error, and all its causes, to stderr.
Displays a warning, with an error object providing detailed information and context.
Returns information about cargo’s version.