1 stable release

1.0.0 Sep 7, 2023

#1311 in Database interfaces

Custom license

7KB
85 lines

Sortable (timestamp-first) unique identifier

Tests Crates.io Documentation

Why?

Random identifiers can be bad for performance when inserting into balanced b-tree indexes.

Variants

variant timestamp bits random bits
u32, i32 16 (hours since unix epoch) 16
u64, i64 40 (seconds since unix epoch) 24
u128, i128 64 (milliseconds since unix epoch) 64

License

☕ Coffee License 2.0


lib.rs:

Sortable (timestamp-first) unique identifier

Why?

Random identifiers can be bad for performance when inserting into balanced b-tree indexes.

Variants

variant timestamp bits random bits
u32, i32 16 (hours since unix epoch) 16
u64, i64 40 (seconds since unix epoch) 24
u128, i128 64 (milliseconds since unix epoch) 64

Usage

use suid::Suid;

println!("{}", u32::suid());
println!("{}", i32::suid());
println!("{}", u64::suid());
println!("{}", i64::suid());
println!("{}", u128::suid());
println!("{}", i128::suid());

License

☕ Coffee License 2.0

Dependencies

~310KB