#uuid #segment #guid #serialization #generate #io #base62

ksuid

A library for efficiently generating, parsing and serializing Segment.io KSUIDs

2 unstable releases

Uses old Rust 2015

0.2.0 Jun 19, 2017
0.1.0 Jun 15, 2017

#8 in #base62

Download history 32/week @ 2024-07-19 68/week @ 2024-07-26 37/week @ 2024-08-02 49/week @ 2024-08-09 105/week @ 2024-08-16 68/week @ 2024-08-23 103/week @ 2024-08-30 61/week @ 2024-09-06 35/week @ 2024-09-13 55/week @ 2024-09-20 102/week @ 2024-09-27 44/week @ 2024-10-04 45/week @ 2024-10-11 28/week @ 2024-10-18 40/week @ 2024-10-25 25/week @ 2024-11-01

141 downloads per month
Used in 4 crates (3 directly)

MIT license

19KB
294 lines

Version Docs

Ksuid

KSUID stands for K-Sortable Unique IDentifier, a globally unique identifier used by Segment.

KSUIDs incorporate a timestamp with 1-second resolution, allowing them to be (roughly) sorted chronologically, as well as a 128-bit random payload in the style of UUIDv4. They can be serialized using a Base62 encoding for compatibility with environments which only support alphanumeric data. The lexicographic ordering of both the binary and string representations preserves the chronological ordering of the embedded timestamp.

See the canonical implementation for more information.

The author of this package is not affiliated with Segment.

This repository contains two separate crates, a library (ksuid) for generating, parsing and serializing KSUIDs and a simple CLI (ksuid-cli) which exposes a subset of this functionality for interactive use.

Benchmarks

The library includes some benchmarks to compare its performance against the canonical implementation. However, the benchmarks use rust's unstable test crate, so they are hidden behind a feature flag. Execute cargo bench --features bench with a nightly version of the compiler to run the benchmarks.

Dependencies

~1–1.5MB
~23K SLoC