Appendix: Glossary - The Cargo Book (original) (raw)

Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The Cargo Book

Glossary

Artifact

An artifact is the file or set of files created as a result of the compilation process. This includes linkable libraries, executable binaries, and generated documentation.

Cargo

Cargo is the Rust package manager, and the primary topic of this book.

Cargo.lock

See lock file.

Cargo.toml

See manifest.

Crate

A Rust crate is either a library or an executable program, referred to as either a library crate or a binary crate, respectively.

Every target defined for a Cargo package is a crate.

Loosely, the term crate may refer to either the source code of the target or to the compiled artifact that the target produces. It may also refer to a compressed package fetched from a registry.

The source code for a given crate may be subdivided into modules.

Edition

A Rust edition is a developmental landmark of the Rust language. Theedition of a package is specified in the Cargo.toml manifest, and individual targets can specify which edition they use. See the Edition Guide for more information.

Feature

The meaning of feature depends on the context:

Index

The index is the searchable list of crates in aregistry.

Lock file

The Cargo.lock lock file is a file that captures the exact version of every dependency used in a workspace orpackage. It is automatically generated by Cargo. SeeCargo.toml vs Cargo.lock.

Manifest

A manifest is a description of a package or aworkspace in a file named Cargo.toml.

A virtual manifest is a Cargo.toml file that only describes a workspace, and does not include a package.

Member

A member is a package that belongs to aworkspace.

Module

Rust’s module system is used to organize code into logical units called_modules_, which provide isolated namespaces within the code.

The source code for a given crate may be subdivided into one or more separate modules. This is usually done to organize the code into areas of related functionality or to control the visible scope (public/private) of symbols within the source (structs, functions, and so on).

A Cargo.toml file is primarily concerned with thepackage it defines, its crates, and the packages of the crates on which they depend. Nevertheless, you will see the term “module” often when working with Rust, so you should understand its relationship to a given crate.

Package

A package is a collection of source files and a Cargo.toml manifest file which describes the package. A package has a name and version which is used for specifying dependencies between packages.

A package contains multiple targets, each of which is acrate. The Cargo.toml file describes the type of the crates (binary or library) within the package, along with some metadata about each one — how each is to be built, what their direct dependencies are, etc., as described throughout this book.

The package root is the directory where the package’s Cargo.toml manifest is located. (Compare with workspace root.)

The package ID specification, or SPEC, is a string used to uniquely reference a specific version of a package from a specific source.

Small to medium sized Rust projects will only need a single package, though it is common for them to have multiple crates.

Larger projects may involve multiple packages, in which case Cargoworkspaces can be used to manage common dependencies and other related metadata between the packages.

Package manager

Broadly speaking, a package manager is a program (or collection of related programs) in a software ecosystem that automates the process of obtaining, installing, and upgrading artifacts. Within a programming language ecosystem, a package manager is a developer-focused tool whose primary functionality is to download library artifacts and their dependencies from some central repository; this capability is often combined with the ability to perform software builds (by invoking the language-specific compiler).

Cargo is the package manager within the Rust ecosystem. Cargo downloads your Rust package’s dependencies (artifacts known as crates), compiles your packages, makes distributable packages, and (optionally) uploads them tocrates.io, the Rust community’s package registry.

Package registry

See registry.

Project

Another name for a package.

Registry

A registry is a service that contains a collection of downloadablecrates that can be installed or used as dependencies for apackage. The default registry in the Rust ecosystem iscrates.io. The registry has an index which contains a list of all crates, and tells Cargo how to download the crates that are needed.

Source

A source is a provider that contains crates that may be included as dependencies for a package. There are several kinds of sources:

See Source Replacement for more information.

Spec

See package ID specification.

Target

The meaning of the term target depends on the context:

Test Targets

Cargo test targets generate binaries which help verify proper operation and correctness of code. There are two types of test artifacts:

Workspace

A workspace is a collection of one or morepackages that share common dependency resolution (with a sharedCargo.lock lock file), output directory, and various settings such as profiles.

A virtual workspace is a workspace where the root Cargo.toml manifest does not define a package, and only lists the workspace members.

The workspace root is the directory where the workspace’s Cargo.tomlmanifest is located. (Compare with package root.)