Simple UUID shortener for Rust
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests initial: add alphabet, expand and shorten uuids Jan 29, 2019
.editorconfig initial: add alphabet, expand and shorten uuids Jan 29, 2019
.gitattributes initial: add alphabet, expand and shorten uuids Jan 29, 2019
.gitignore
.rustfmt.toml
COPYRIGHT initial: add alphabet, expand and shorten uuids Jan 29, 2019
Cargo.toml
README.md

README.md

shorter_uuid

Latest version Documentation

This create is a simple UUID shortener inspired by keiko/uuid-shortener, pascaldevink/shortuuid and skorokithakis/shortuuid.

Usage

Add this to your Cargo.toml:

[dependencies]
shorter_uuid = { version = "0.1", default_features = false }

Note: Disabling of default features disables proptest arbitrary module.

Then use it in your project like that:

use uuid::Uuid;
use shorter_uuid::{Expand, Shorten};

fn main() -> Result<(), Error> {
    // Expands string with `BASE57` alphabet.
    let e = Uuid::expand("mavTAjNm4NVztDwh4gdSrQ")?;
    let u = Uuid::parse_str("806d0969-95b3-433b-976f-774611fdacbb")?;
    
    // Encodes `u` with `BASE57` alphabet.
    assert_eq!(format!("{}", u.shorten()), "mavTAjNm4NVztDwh4gdSrQ"); 
    assert_eq!(e, u);
    Ok(())
}

Check API documentation for details.