Closed broofa closed 4 months ago
@broofa I was thinking it might be helpful to provide an API for generating a uuid8, such as v8(buf)
. The method would manage bit shifting / placement, and return a compliant uuid8 populated with the first 122 bits of the buffer. Thoughts on wether or not this utility belongs?
@broofa I was thinking it might be helpful to provide an API for generating a uuid8, such as v8(buf). The method would manage bit shifting / placement, and return a compliant uuid8 populated with the first 122 bits of the buffer. Thoughts on wether or not this utility belongs?
Let's hold off on this until we see demand for it. I suspect v8 UUIDs will generally be a pretty niche use case compared to other versions, and experience has taught me to be cautious about expanding the API surface. It's 10x harder to remove an API than it is to add it.
[Stacking this on top of #754, which I expect will go in shortly]
We actually snuck in the change to allow version 8 in the validation regex as part of #651, which is really all that's required to support v8 UUIDs. There's no formal algorithm for v8 ("experiment or vendor-specific") ids, so the only impact on this library is that such ids must properly
validate()
andversion()
.This PR adds tests for those cases. I've also taken the opportunity to refactor the
validate
andversion
tests to be "table-driven" from a common set of test cases, which I've fleshed out to include the original cases we had, plus a few additional ones.