Tempo ID
Short IDs with temporal ordering.
A library to generate URL-friendly, unique, and short IDs that are sortable by time. Inspired by nanoid and UUIDv7.
See tempoid.dev for more information.
Motivation
- URL-friendly: The IDs are easy to select and copy.
- Unique: The IDs are practically unique and can be used in distributed systems.
- Short: The IDs are shorter than UUIDs because they are encoded with a larger alphabet.
- Sortable: The IDs are sortable by time because a timestamp is encoded in the beginning of the ID.
- Customizable: You can configure the ID length and the characters used.
Example ID:
0uoVxkjTFsrRX30O5B9fX
<------><----------->
Time Random
Collisions
- Same millisecond: There can be only a collision if two IDs are generated in the same millisecond.
- Low probability: Even if two IDs are generated in the same millisecond, the probability of a collision is very low.
The 13 random characters exceed the randomness of UUIDv7 (≈1023 vs ≈1022).
Getting Started
# Cargo.toml
[dependencies]
tempoid = <version>
Usage
use ;
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.