#uuid #safe #fast #uuidv1

shortid

uuidv1 generator and variant. safe and fast.

7 stable releases

✓ Uses Rust 2018 edition

1.0.6 Dec 6, 2019
1.0.5 Nov 12, 2019
1.0.4 Nov 8, 2019
1.0.3 Nov 7, 2019

#228 in Encoding

Download history 30/week @ 2020-01-18 9/week @ 2020-02-08 61/week @ 2020-02-15 68/week @ 2020-02-22 1/week @ 2020-02-29 14/week @ 2020-03-07 7/week @ 2020-03-14 47/week @ 2020-03-21 52/week @ 2020-03-28 12/week @ 2020-04-04 50/week @ 2020-04-11 1/week @ 2020-04-18 4/week @ 2020-04-25 2/week @ 2020-05-02

109 downloads per month

AGPL-3.0

17KB
322 lines

shortid

Example

use shortid::*;

fn to_string(src:&[u8])->String {
    src
        .into_iter()
        .map(|val| format!("{:0>2x}", val))
        .collect()
}

fn main() {

    let mac = [1,2,3,4,5,6];
    let epoch = 0;

    println!("{}" , to_string(&uuidv1(mac).unwrap()));

    let mac = [1,2,3,4];
    println!("{}" , to_string(&next_short_128(mac).unwrap()));

    let mac = [1,2,3];
    println!("{}" , to_string(&next_short_96(mac,epoch).unwrap()));

    println!("{}" , to_string(&next_short_64(epoch).unwrap()));

}

License: AGPL-3.0


lib.rs:

Example

use shortid::*;

fn to_string(src:&[u8])->String {
    src
        .into_iter()
        .map(|val| format!("{:0>2x}", val))
        .collect()
}

fn main() {

    let mac = [1,2,3,4,5,6];
    let epoch = 0;

    println!("{}" , to_string(&uuidv1(mac).unwrap()));

    let mac = [1,2,3,4];
    println!("{}" , to_string(&next_short_128(mac).unwrap()));

    let mac = [1,2,3];
    println!("{}" , to_string(&next_short_96(mac,epoch).unwrap()));

    println!("{}" , to_string(&next_short_64(epoch).unwrap()));

}

Dependencies

~420–750KB
~17K SLoC