liveBook · Manning

Path dependency

As explained in Refactoring to Rust

A path dependency is a package dependency resolved from a specified filesystem path instead of a package registry.

A path dependency tells Cargo to find a crate in a specified filesystem location instead of downloading it from crates.io. This supports using an unpublished local crate alongside another Rust project. section 4.5 section 4.7

Using a local calculator crate

An NGINX handler can depend on a neighboring calculate crate with `calculate = { path = "../calculate" }`, then call `calculate::evaluate(body)`. When the crate is consumed by Rust code, configure it to produce both `rlib` and `cdylib` files.

How Refactoring to Rust covers it

How deep it goes
Defines the dependency mechanism and demonstrates its declaration, then addresses library outputs needed for Rust linking.
Examples
Uses a local calculate crate, an NGINX handler, and a relative path in Cargo.toml.
What it assumes
Assumes a Cargo project and a crate directory, while demonstrating the dependency declaration from a concrete neighboring-project layout.
What you can do after
Operate/configure Cargo to include a local crate and adjust its library targets for Rust and C consumers.
How it connects
Connects Cargo, crates.io, Rust crates, and rlib or cdylib library outputs.

Related concepts

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