#uuid #safe #performance #uuidv1

shortid

uuidv1 generator and variant. safe and fast.

7 stable releases

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

#1218 in Encoding

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

~265–720KB
~17K SLoC