#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

20 releases

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

#664 in Rust patterns

Download history 176/week @ 2024-01-22 148/week @ 2024-01-29 298/week @ 2024-02-05 221/week @ 2024-02-12 160/week @ 2024-02-19 500/week @ 2024-02-26 2099/week @ 2024-03-04 658/week @ 2024-03-11 1025/week @ 2024-03-18 1595/week @ 2024-03-25 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

1,723 downloads per month
Used in 30 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

~1.5MB
~34K SLoC