A library crate packages functionality behind a public interface; unlike a binary crate, it does not create an executable. In a Rust project, Cargo creates a library with `--lib` and a `lib.rs` file. section 5.1
To extract a component into a local library crate:
- Create it with `cargo new handle-errors --lib` and move the component code into its `src/lib.rs`. section 5.1.3
- Add the crate to the application’s `Cargo.toml` using a local path, then import its public functionality where needed. section 5.1.3
- Update the crate’s dependencies for libraries it uses; the extracted error-handling crate, for example, depends on Warp. section 5.1.3
Extracting error handling
A web service moves its error code into a `handle-errors` library crate, adds that crate by local path, and imports its error type and handler. This removes the old module declaration and lets multiple files use the extracted functionality. section 5.1.3
Figure 5.2 After creating a new library in our application folder, we can add it to the Cargo dependencies and specify a local path; afterward, we use it as any other external library in our files.
Shows how a library in the application folder becomes a Cargo path dependency. section 5.1.3
A project can also expose its application code as a library while retaining a binary that starts the server. Public library functions can then be used by an integration-test project. section 11.3.1

