#tor #tor-arti #arti

tor-units

Provides macros for types which are constrained within a range, ensuring invalid values are unrepresentable

32 releases (20 breaking)

0.30.0 May 1, 2025
0.28.0 Mar 3, 2025
0.25.0 Dec 2, 2024
0.24.0 Oct 31, 2024
0.0.0 Jun 24, 2021

#404 in Rust patterns

Download history 1453/week @ 2025-02-01 2942/week @ 2025-02-08 1420/week @ 2025-02-15 1363/week @ 2025-02-22 1646/week @ 2025-03-01 1387/week @ 2025-03-08 1410/week @ 2025-03-15 993/week @ 2025-03-22 1416/week @ 2025-03-29 965/week @ 2025-04-05 2248/week @ 2025-04-12 1889/week @ 2025-04-19 2038/week @ 2025-04-26 1880/week @ 2025-05-03 2455/week @ 2025-05-10 3897/week @ 2025-05-17

10,561 downloads per month
Used in 63 crates (8 directly)

MIT/Apache

89KB
1.5K SLoC

tor-units

Safe wrappers for primitive numeric types.

Overview

This crate is part of Arti, a project to implement Tor in Rust. It provides safe wrappers for primitive numeric wrappers used in other parts of Arti. In particular, it provides:

  • a bounded i32 with both checked and clamping constructors,
  • an integer milliseconds wrapper with conversion to Duration
  • an integer seconds wrapper with conversion to Duration
  • a percentage wrapper, to prevent accidental failure to divide by 100.
  • a SendMeVersion which can be compared only.

Compile-time features

  • memquota-memcost -- implement tor_memquota::HasMemoryCost for many types. (Does not actually force compiling in memory quota tracking; that's memquota in tor-memquota and higher-level crates.)

  • full -- Enable all features above.

License: MIT OR Apache-2.0

Dependencies

~0.3–10MB
~98K SLoC