#tor #tor-arti #arti #tor-units

tor-units

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

32 releases (20 breaking)

new 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

#396 in Rust patterns

Download history 1605/week @ 2025-01-10 1544/week @ 2025-01-17 1409/week @ 2025-01-24 1101/week @ 2025-01-31 3310/week @ 2025-02-07 1393/week @ 2025-02-14 1440/week @ 2025-02-21 1500/week @ 2025-02-28 1355/week @ 2025-03-07 1556/week @ 2025-03-14 1045/week @ 2025-03-21 1317/week @ 2025-03-28 1000/week @ 2025-04-04 2107/week @ 2025-04-11 1907/week @ 2025-04-18 1746/week @ 2025-04-25

6,963 downloads per month
Used in 59 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
~97K SLoC