unique_id 0.1.1

A trait and implementations for unique ID generators.
Documentation

Crate unique_id

A trait and implementations for unique ID generators.

MIT License Minimum Rust Version crates.io docs.rs travis.ci GitHub stars

This crate provides three simple traits, starting with Generator. This will return successive unique identifiers. Two implementations of this trait are provided which provide unique string and integer values respectively.

Example

The following shows an example of the StringGenerator implementation.

use unique_id::Generator;
use unique_id::string::StringGenerator;

let gen = StringGenerator::default();
let mut last = gen.next_id();
for _ in 1..100_000 {
    let next = gen.next_id();
    assert_ne!(last, next);
    last = next;
}

Changes

Version 0.1.1

  • Added trait GeneratorFromSeed and implementation for SequenceGenerator.
  • Added benchmark to compare the two current implementations.

Version 0.1.0

  • Simple traits Generator, GeneratorWithInvalid, and GeneratorFromStr.
  • StringGenerator using UUIDs
  • SequenceGenerator using i64

TODO

  1. Decide on better FromStr support.