#unique-id #file-path #human-readable #url-safe #unicode #white-space #characters

hr-id

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

8 releases (4 breaking)

0.5.1 Dec 20, 2023
0.5.0 Nov 6, 2023
0.4.1 Sep 3, 2023
0.4.0 Jul 3, 2023
0.1.0 Feb 25, 2022

#359 in Text processing

Download history 42/week @ 2024-03-11 24/week @ 2024-03-18 50/week @ 2024-03-25 104/week @ 2024-04-01 24/week @ 2024-04-08 24/week @ 2024-04-15 24/week @ 2024-04-22 23/week @ 2024-04-29 23/week @ 2024-05-06 40/week @ 2024-05-13 37/week @ 2024-05-20 47/week @ 2024-05-27 37/week @ 2024-06-03 47/week @ 2024-06-10 31/week @ 2024-06-17 50/week @ 2024-06-24

166 downloads per month
Used in 18 crates (4 directly)

Apache-2.0

12KB
261 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.5–4.5MB
~81K SLoC