Crates.io | oid2 |
lib.rs | oid2 |
version | 0.1.0 |
source | src |
created_at | 2023-04-15 21:42:10.275782 |
updated_at | 2023-04-15 21:42:10.275782 |
description | An id schema that is compatible with uuid, lexicographcally sorted (won't explode database indexes), readable, and double-click-copyable. |
homepage | |
repository | |
max_upload_size | |
id | 840211 |
size | 8,921 |
oid
An id scheme. Why another one?
lexicographically sortable
- uuidv4
is not sorted and will explode database indexes. Like ulid
, oid
is lexicographically sortable.team_0da0fa0e02cssbhkanf04c_srb0
team_srb0
a827f03c-f5b0-40ef-8d53-3fb3cdf4e055
. Then try this oid
: team_0da0fa0e02cssbhkanf04c_srb0
label!(Team, "team");
label!(User, "usr");
label!(Transaction, "tx");
fn main() {
let id = Team::oid();
// e.g. id: team_0da0fa0e02cssbhkanf04c_srb0
println!("id: {}", id);
// e.g. id: team_srb0
// e.g. uuid: a827f03c-f5b0-40ef-8d53-3fb3cdf4e055
println!("short: {}", id.short());
println!("uuid: {}", id.uuid());
// We didn't use a Label, so it's simply missing.
let id = new_oid();
// e.g. id: 0da0fa0e02cssbhkanf04c_srb0
println!("id: {}", id);
}