[][src]Crate 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()));

}

Enums

Error

Functions

next_short_64

for standalone the number of threads less than 256 epoch: 100 nanosecond timestamp , unix epoch Max IDs per Second : 20_000_000

next_short_96

42 bit timestamp 819_200 ns * 2 ^ 42 (114 years) 14 bit sequence 16 bit worker id 24 bit machine_id Big Endian Order epoch: 100 nanosecond timestamp , unix epoch Max IDs per Second : 20_000_000

next_short_128

for compatible UUID 16 bit worker id and 24 bit machine_id

next_short_128_sync

uuidv1 generator

short_64_to_96
short_64_to_128
short_96_to_128
uuidv1

uuidv1 generator