Expand description
§Sequential ID Generator
This crate provides a simple sequential ID generator that can be used to generate unique sequential IDs. The generator allows you to specify the step to increment the value by. To use the generator, you need to ensure that only one instance of the generator is created. This can be achieved by using a singleton pattern or by using a global variable.
The crate provides a Generator
trait that you can implement to create your own generator. The crate also
provides a SimpleGenerator
that you can use out of the box.
The crate is no_std
compatible. To use the crate in a no_std
environment, you need to disable the default
features and enable the no_std
feature in your Cargo.toml
.
[dependencies]
sequential-gen = { version = "0.1", default-features = false, features = ["no_std"] }
§Usage
use sequential_gen::prelude::*;
lazy_static! {
static ref GENERATOR: SimpleGenerator<u128> = SimpleGenerator::new(1u128);
}
fn main() {
let id = GENERATOR.generate();
// Use your ID
}
§Features
The following features are available:
default
: Enables the standard library.no_std
: Disables the standard library.uuid
: Enables support for generating UUIDs. This feature is not available in ano_std
environment.