liveBook · Manning

Cargo

As explained in Rust Servers, Services, and Apps

Cargo is Rust's build system and package manager for creating, compiling, testing, and managing Rust projects and dependencies.

Cargo creates and organizes Rust projects, compiles and runs binaries, and manages dependencies through project manifests. Its workspace support groups related binary and library projects under one repository. section 2.2.2 section 3.1.1

A typical project workflow uses Cargo to:

  • Create a workspace and member projects with cargo new, including binary and library packages. section 2.2.2
  • Declare workspace membership, dependencies, and binary names in Cargo.toml. section 3.1.1
  • Build and run one workspace member or a named binary with cargo run -p and cargo run --bin. section 2.2.2 section 3.1.1

Workspace for a server project

Create a scenario1 workspace containing tcpclient, tcpserver, http, and httpserver, then run the TCP server with cargo run -p tcpserver. A second workspace, ezytutors, contains tutor-nodb, whose basic-server binary runs with cargo run -p tutor-nodb --bin basic-server. section 2.2.2 section 3.1.1

Figure 2.2 Cargo workspace structure for scenario 1

Workspace structure shows how Cargo places multiple related Rust packages beneath a shared root. section 2.2.2

How Rust Servers, Services, and Apps covers it

How deep it goes
Explains workspace layout, package creation, manifests, dependencies, binary declarations, and run commands, but not build-system internals.
Examples
Uses scenario1 and ezytutors workspaces, TCP client-server binaries, an HTTP library, and a basic Actix health server.
What you can do after
Builds and operates multi-package Rust projects by creating workspaces, configuring manifests, adding dependencies, and running named binaries.
How it connects
Connects Cargo with Rust workspaces, Cargo.toml, binary packages, library packages, dependencies, and Actix Web applications.

Also explained in

Compare how 5 books explain Cargo →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Rust Servers, Services, and Apps. The section links point to the parts of the book it draws on.