#tor #arti #wrapper #safe-wrapper #numeric #integer #constructor

tor-units

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

22 releases (10 breaking)

0.20.0 Jun 27, 2024
0.18.0 Apr 30, 2024
0.6.5 Mar 4, 2024
0.6.4 Sep 5, 2023
0.0.0 Jun 24, 2021

#827 in Rust patterns

Download history 1085/week @ 2024-04-01 1550/week @ 2024-04-08 327/week @ 2024-04-15 294/week @ 2024-04-22 612/week @ 2024-04-29 437/week @ 2024-05-06 360/week @ 2024-05-13 873/week @ 2024-05-20 603/week @ 2024-05-27 475/week @ 2024-06-03 909/week @ 2024-06-10 1495/week @ 2024-06-17 1240/week @ 2024-06-24 1347/week @ 2024-07-01 244/week @ 2024-07-08 820/week @ 2024-07-15

3,982 downloads per month
Used in 31 crates (8 directly)

MIT/Apache

30KB
579 lines

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.

License: MIT OR Apache-2.0


lib.rs:

Dependencies

~300–750KB
~17K SLoC