uuid-b64

Build Status

A UUID wrapper that has a base64 display and serialization

What?

A newtype around UUIDs that:

```rust let knownid = Uuid::parsestr("b0c1ee86-6f46-4f1b-8d8b-7849e75dbcee").unwrap(); let asb64 = UuidB64::from(knownid); asserteq!(asb64.to_string(), "sMHuhm9GTxuNi3hJ51287g");

let parsedb64: UuidB64 = "sMHuhm9GTxuNi3hJ51287g".parse().unwrap(); asserteq!(parsedb64, asb64);

let rawid = Uuid::newv4(); asserteq!(rawid.tostring().len(), 36); let uuidb64 = UuidB64::from(rawid); asserteq!(uuidb64.tostring().len(), 22); ```

UuidB64::new creates v4 UUIDs, because... that's what I use. I'm open to hearing arguments about why this is a ridiculous decision and I should have made new be new_v4.

Why?

UUIDs are great:

That said, the standard representation for UUIDs is kind of annoying:

I guess that's it. Base64 is a more human-friendly representation of UUIDs:

That said, there are drawbacks to something like this:

Usage

Just use UuidB64 everywhere you would use Uuid, and use UuidB64::from to create one from an existing UUID.

Features

Contributing

Testing

Most tests are standard: cargo test or cargo test --features serde, but if you want to test the diesel integration (the diesel-uuid feature) then we need a running postgres instance. Assuming that you have docker running locally and are in bash you can do ./run-tests.sh to execute all tests.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.