The Cargo.toml file uses the TOML format. See
the example in Program 1. It is divided in
multiple sections denoted by square brackets ([]):
The
packagesection regroups all the description of the package itself. See Table 1 for a description of each field and the official format in The Manifest Format.The
dependenciessection gathers all crates this package needs to compile.There can be at most one
libsection. It describes a binary library to generate. If this section is not defined, but the filesrc/lib.rsexists, it will be used as the default library.There can be any number of
binsections. The double square brackets ([[]]) means that it is an array. Each[[bin]]section describes a binary program to generate. Thepathkey gives the code source file that contains the entry point (e.g.: themain()function). If nobinsection is provided, and a filesrc/main.rsexists, then a defaultbinsection is created with the file as the main source file and as a name the name of the package.
Table 1:The fields of the package section
Field | Description |
|---|---|
| The package name. |
| The package version. |
| The Rust edition used to compile the package. |
| The package license. Note the |
| A package description. |
| URL to the package’s documentation. |
| URL to the package’s homepage, if different from documentation and repository URLs. |
| The URL to the package’s repository. |
| The authors (array format). |
| The README file. |
| An array of files to exclude from the package. Those files will not be published. |
| An array of up to 5 categories in which to classify this package. See All Valid Category Slugs. |
| An array of up to 5 keywords, used when searching for a crate on the registry. Any word is accepted. |
[package]
name = "ansiconv"
version = "1.2.3"
edition = "2024"
license = "CECILL-B AND CECILL-C"
description = "A library and tools to parse ANSI escape codes from text."
repository = "https://gitlab.com/cnrgh/infotools/ansiconv"
authors = ["Pierrick Roger <pierrick.roger@cea.fr>"]
readme = "README.md"
exclude = ["Makefile"]
categories = ["command-line-utilities"]
keywords = ["shell", "library", "ANSI", "escape", "text"]
[dependencies]
build_html = "2.8.0"
clap = { version = "4.6.1", features = ["derive"] }
env_logger = "0.11.10"
glob = "0.3.3"
log = "0.4.32"
[lib]
path = "src/lib.rs"
test = true
[[bin]]
name = "ansi2tex"
path = "src/cli_ansi2tex.rs"
[[bin]]
name = "ansi2html"
path = "src/cli_ansi2html.rs"Program 1:Example of a Cargo.toml file