#unique-id #file-path #url-safe #human-readable #unicode #serialization #uuid

hr-id

A human-readable unique ID which supports Unicode, safe for URLs and file paths

9 releases (5 breaking)

0.6.0 Aug 13, 2024
0.5.1 Dec 20, 2023
0.5.0 Nov 6, 2023
0.4.0 Jul 3, 2023
0.1.0 Feb 25, 2022

#359 in Text processing

Download history 18/week @ 2024-07-01 13/week @ 2024-07-08 72/week @ 2024-07-15 30/week @ 2024-07-22 54/week @ 2024-07-29 43/week @ 2024-08-05 218/week @ 2024-08-12 32/week @ 2024-08-19 78/week @ 2024-08-26 16/week @ 2024-09-02 31/week @ 2024-09-09 42/week @ 2024-09-16 76/week @ 2024-09-23 35/week @ 2024-09-30 8/week @ 2024-10-07 23/week @ 2024-10-14

142 downloads per month
Used in 19 crates (4 directly)

Apache-2.0

12KB
263 lines

hr-id

A human-readable unique ID for Rust which:

  • supports Unicode
  • disallows whitespace
  • disallows common control characters .. and each of /~$`&|=^{}<>'\?:@#()
  • disallows ASCII control characters (bytes with integer value < 32)
  • can be used to represent a domain name or URI segment but not an entire URL
  • implements From<Uuid>
  • implements Serialize and Deserialize with the serde feature
  • implements ToStream and FromStream with the destream feature

lib.rs:

A human-readable ID which is safe to use as a component in a URI path. and supports constant Labels.

Features:

  • hash: enable support for async-hash
  • serde: enable support for serde
  • stream: enable support for destream
  • uuid: enable support for uuid

Example:

use hr_id::{label, Id, Label};

const HELLO: Label = label("hello"); // unchecked!
let world: Id = "world".parse().expect("id");

assert_eq!(format!("{}, {}!", HELLO, world), "hello, world!");
assert_eq!(Id::from(HELLO), "hello");
assert!(Id::from_str("this string has whitespace").is_err());

Dependencies

~2.6–4.5MB
~83K SLoC