dylanhart / ulid-rs

This is a Rust implementation of the ulid project

Home Page:https://crates.io/crates/ulid

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UUIDv7 conversions

dylanhart opened this issue · comments

UUIDv7 conversions that keep the timestamp and random value would be nice to have.

How would this work? ULIDs have 80 bits of randomness, but UUIDv7s have only 74 (4 bits are fixed for version and 2 bits are fixed for variant).

I think the conversions done now work for converting a UUIDv7 into a ULID. The 48 bit timestamp is preserved and you can pretend that you have 80 bits of randomness if you want.

But wouldn't converting a ULID into a UUIDv7 require overwriting six of the randomness bits with the six fixed bits demanded? So you can't really keep the (entire) random value, right?