The Arti project is the team's ongoing effort to write a pure-Rust implementation of Tor.
Arti is not yet feature complete but it's in active development. That's where you want to go if you're interested in Tor and Rust together.
This document describes something with niche interest: the C implementation of Tor can expose Rust crates which are used for internal testing, benchmarking, comparison, fuzzing, and so on. This could be useful for comparing the C implementation against new Rust implementations, or for simply using Rust tooling for writing tests against C.
Right now we are only using this mechanism for one crate:
tor-c-equix-- Wraps thesrc/ext/equixmodule, containing Equi-X and HashX algorithms.
This is not a stable API and we have no plans to develop a stable Rust interface to the C implementation of Tor.
We use only a few of the standard Rust file types in order to build our wrapper crates. Here's a summary:
Cargo.tomlin the repository root defines a Cargo workspace. It will list all subdirectories that contain crates with their ownCargo.toml.- A per-crate
Cargo.tomldefines metadata and dependencies. These crates should all be markedpublish = false. build.rsimplements a simple build system that does not interact with autotools. It uses theccandbindgencrates to get from.c/.hfiles to a static library and matching auto-generated bindings. Prefer to include bindgen wrapper headers inline withinbuild.rsinstead of adding.hfiles that are only used by the Rust bindings.lib.rspublishes the low-levelffiinterface produced withccandbindgen. This is also where we can add any wrappers or additions we want for making the Rust API more convenient.