liveBook · Manning

Workspace

As explained in Rust Servers, Services, and Apps

A Cargo workspace is a set of related Rust packages managed and built together by Cargo.

A Cargo workspace is a container project that groups related Rust packages and lets Cargo manage them as one unit. It can contain binary and library projects while keeping their source trees and manifests organized under a shared root. section 2.2.2 section 1.3.2

Declare the workspace in the root Cargo.toml with a [workspace] table and a members list. Each listed package remains an independent Cargo project, but commands can target it from the workspace root. section 2.2.2 section 3.1.1

A TCP and HTTP workspace

Create scenario1, then add tcpserver, tcpclient, httpserver, and the library package http. The root manifest lists all four members. Run a selected binary with `cargo run -p tcpserver`; the same structure supports separate server, client, protocol, and application projects in one repository. section 2.2.2

A web-service workspace

Create ezytutors as the root, declare `tutor-nodb` as a member, and add the web service beneath it. Run its named binary with `cargo run -p tutor-nodb --bin basic-server`, then access the `/health` route. section 3.1.1

Figure 2.2 Cargo workspace structure for scenario 1

Use the workspace diagram to see the root project and its binary and library members as one project structure. section 2.2.2

How Rust Servers, Services, and Apps covers it

How deep it goes
Defines workspace roots and members, demonstrates manifest configuration and package commands, but does not develop advanced workspace architecture.
Examples
Uses scenario1 with TCP and HTTP packages and ezytutors with a tutor-nodb web-service package.
What it assumes
Assumes familiarity with Rust projects and Cargo commands while teaching workspace roots, members, and package relationships through construction.
What you can do after
Operate/configure Cargo workspaces, declare members, create packages, and run a selected binary from the workspace root.
How it connects
Connects Cargo with Rust packages, binary projects, library projects, module organization, and Git repositories.

Also explained in

Compare how 2 books explain workspace →

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.