#tor #tor-arti #arti

tor-units

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

31 releases (19 breaking)

new 0.29.0 Apr 1, 2025
0.28.0 Mar 3, 2025
0.27.0 Feb 7, 2025
0.25.0 Dec 2, 2024
0.0.0 Jun 24, 2021

#184 in Rust patterns

Download history 2573/week @ 2024-12-11 1670/week @ 2024-12-18 714/week @ 2024-12-25 1232/week @ 2025-01-01 1523/week @ 2025-01-08 1840/week @ 2025-01-15 1382/week @ 2025-01-22 1041/week @ 2025-01-29 3293/week @ 2025-02-05 1529/week @ 2025-02-12 1176/week @ 2025-02-19 1562/week @ 2025-02-26 1336/week @ 2025-03-05 1718/week @ 2025-03-12 1025/week @ 2025-03-19 1178/week @ 2025-03-26

5,610 downloads per month
Used in 56 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–11MB
~96K SLoC