Cargo (software)

from Wikipedia, the free encyclopedia
Cargo
Basic data

Maintainer Rust Project Developers
Current  version 0.46.1
( July 30, 2020 )
programming language Rust
category Package management
License MIT license
doc.rust-lang.org/stable/cargo/

Cargo is package management software for Rust packages called Crate . Cargo is installed by rustupdefault using the Rust toolchain installation program ; Cargo uses the TOML file format to manage package metadata .

Functions

Cargo is used as the central tool for managing Rust packages. It takes on the following tasks for each package:

  • the management of the metadata about the package
  • the resolution and compilation of the dependencies
  • calling the reference compiler rustcwith the appropriate parameters
  • the enforcement of Rust conventions for uniform package management

Package structure

Rust packages consist of a defined structure:

  • the files Cargo.toml and Cargo.lock in the root directory
  • the source code files in src /
  • optional:

manifest

The package manifest is in the Cargo.toml and looks like this:

[package]
name = "hello_world"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]

[dependencies]
regex = "1"
rand = { git = "https://github.com/rust-lang-nursery/rand.git" }
lazy_static = "*"

[dev-dependencies]
mysql = "16.0.1"

The category contains packagebasic information about the package such as name and version, as well as the authors involved. The category dependenciesincludes all the dependencies of the package, categories such as dev-dependenciesor profile.*allow you to specify separate settings for tests or similar scenarios.

The Cargo.lock file contains the exact revision data of the corresponding dependencies and is automatically generated and maintained by Cargo.

crates.io

Globe icon of the infobox
crates.io
languages English
Registration no, only for uploading your own crates
On-line (currently active)
https://crates.io

The official repository for crates is hosted at crates.io . A GitHub account is required to upload your own crates . As of Rust 1.34.0, alternative repositories can also be integrated into Cargo, previously only crates.io could be used.

Web links

Individual evidence

  1. Release 0.46.1 . July 30, 2020 (accessed July 31, 2020).
  2. github.com .
  3. Why Cargo exists. Retrieved April 22, 2018 .
  4. Cargo.toml vs Cargo.lock. Retrieved April 22, 2019 .
  5. ^ The Manifest Format - The Cargo Book. Retrieved April 23, 2019 .
  6. Publishing on crates.io. Retrieved April 22, 2019 .
  7. Programming language: Rust 1.34 allows alternatives to crates.io. Retrieved April 22, 2019 .