Skip to content

seigert/shorter-uuid-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Simple UUID shortener for Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages