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 |
#704 in Encoding
107 downloads per month
Used in 19 crates
(4 directly)
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
andDeserialize
with theserde
feature - implements
ToStream
andFromStream
with thedestream
feature
lib.rs
:
A human-readable ID which is safe to use as a component in a URI path.
and supports constant Label
s.
Features:
hash
: enable support forasync-hash
serde
: enable support forserde
stream
: enable support fordestream
uuid
: enable support foruuid
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
~81K SLoC