| Crates.io | caretta-id |
| lib.rs | caretta-id |
| version | 0.11.0-rc.2 |
| created_at | 2025-11-07 23:41:45.454318+00 |
| updated_at | 2025-12-15 22:12:22.848043+00 |
| description | Random human-friendly id for personal distributed system |
| homepage | https://github.com/fluo10/caretta-id |
| repository | https://github.com/fluo10/caretta-id |
| max_upload_size | |
| id | 1922345 |
| size | 192,561 |
A human-friendly 7 characters identifier format (e.g. 123abcd).
For a language agnostic specification of the caretta-id format, see SPECS.md
use caretta_id::CarettaId;
let id = CarettaId::random();
println!("{}", id); // e.g. "123abcd"
Traditional identifier systems face challenges in distributed environments:
caretta-id bridges the gap between human readability and technical requirements.
Add this to your Cargo.toml:
[dependencies]
caretta-id = "0.10.0"
# With optional features
caretta-id = { version = "0.10.0", features = ["arbitrary", "serde", "rusqlite", "sea-orm", "prost", "redb"] }
This crate support no_std.
For no_std environment, you'll need to disable default features.
[dependencies]
caretta-id = { version = "0.10.0", default-features = false }
arbitrary: arbitrary::Arbitrary support for fuzzing tests.serde: Serialization/deserialization supportrusqlite: SQLite database integrationsea-orm: SeaORM ORM integrationprost: Protocol Buffers supportredb: redb integrationuse caretta_id::CarettaId;
// Generate random caretta-id
let caretta_id = CarettaId::random();
// e.g. `123abcd`
println!("'{}'", caretta_id);
// Parse from string
let valid_id: CarettaId = "012atvw".parse()?;
// When decoding from BASE32, ambiguous characters (1/l/I, 0/o, v/u) are treated as 1, 0 and v respectively, so they do not cause errors.
let also_valid_id: CarettaId = "ol2atuw".parse()?;
assert_eq!(valid_id, also_valid_id);
// Convert to/from integer
let num: u64 = valid_id.into();
let id_from_int: CarettaId = num.try_into()?;
assert_eq!(valid_id, id_from_int);
// Lossy conversion from oversized int is allowed.
let id_from_overflowed_int = CarettaId::from_u64_lossy(CarettaId::CAPACITY + num);
assert_eq!(valid_id, id_from_overflowed_int);
Licensed under either of:
at your option.