Skip to content

AdeThorMiwa/crockford-uuid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

crockford-uuid

Here's an example of a crockford-uuid:

4s0y2vz7sf4vghnznytz9gvq6

A crockford-uuid Uuid is a unique 120-bit value, stored as 15 bytes identifier, and a fixed number checksum character derived from the identifier for value's integrity check.

The uniqueness property is not strictly guaranteed, however for all practical purposes, it can be assumed that an unintentional collision would be extremely unlikely as the 120 bit key space is about the same size as the number of bacterial cells in existence on the planet. :)

Getting started

Add the following to your Cargo.toml:

crockford-uuid = "0.1.2"

When you want a identifier, you can generate one:

use crockford-uuid::Uuid;

let id = Uuid::new();

If you have a crockford-uuid value, you can use its string literal, BigUint and Bytes values inline:

use uuid::Uuid;

const from_string_lit: Uuid = "4s0y2vz7sf4vghnznytz9gvq6".try_into().unwrap();
const from_big_uint: Uuid = BigUint::parse_bytes(b"471569087780948647371060810118848519319753452797", 10).unwrap().try_into().unwrap();

You can also convert crockford-uuid to be used as a string literal, BigUint, Vec<u8> (Bytes)

const to_str = Uuid::to_string();
const to_big_uint: BigUint = Uuid::new().into();
const to_vec: Vec<u8> = Uuid::new().into();

For more details on using crockford-uuid, see the library documentation.

References

https://learning.oreilly.com/library/view/api-design-patterns/9781617295850/OEBPS/Text/06.htm#:-:text=6.3.3 https://www.crockford.com/base32.html

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages