31 releases (15 breaking)

0.19.0 Jun 5, 2024
0.17.0 Apr 2, 2024
0.12.1 Mar 4, 2024
0.10.0 Dec 4, 2023
0.0.0 Jun 24, 2021

#317 in Parser implementations

Download history 513/week @ 2024-02-26 2036/week @ 2024-03-04 641/week @ 2024-03-11 990/week @ 2024-03-18 1490/week @ 2024-03-25 1000/week @ 2024-04-01 1391/week @ 2024-04-08 265/week @ 2024-04-15 242/week @ 2024-04-22 526/week @ 2024-04-29 311/week @ 2024-05-06 217/week @ 2024-05-13 816/week @ 2024-05-20 560/week @ 2024-05-27 440/week @ 2024-06-03 808/week @ 2024-06-10

2,667 downloads per month
Used in 25 crates (9 directly)


24K SLoC


Parse and represent directory objects used in Tor.


Tor has several "directory objects" that it uses to convey information about relays on the network. They are documented in dir-spec.txt.

This crate has common code to parse and validate these documents. Currently, it can handle the metaformat, along with certain parts of the router descriptor type. We will eventually need to handle more types.

This crate is part of Arti, a project to implement Tor in Rust.

Design notes

The crate is derived into three main parts. In the (private) parse module, we have the generic code that we use to parse different kinds of network documents. In the types module we have implementations for parsing specific data structures that are used inside directory documents. Finally, the [doc] module defines the parsers for the documents themselves.


build_docs: enable code to construct the objects representing different network documents.

routerdesc: enable support for the "router descriptor" document type, which is needed by bridge clients and relays.

ns-consensus: enable support for the "ns consensus" document type, which some relays cache and serve.

Caveat haxxor: limitations and infelicities

TODO: This crate requires that all of its inputs be valid UTF-8: This is fine only if we assume that proposal 285 is implemented in mainline Tor.

TODO: This crate has several pieces that could probably be split out into other smaller cases, including handling for version numbers and exit policies.

TODO: Many parts of this crate that should eventually be public aren't.

TODO: this crate needs far more tests!

License: MIT OR Apache-2.0


~502K SLoC