Lexicoid

Build Status Crates.io docs.rs

Short & stable IDs based on timestamps.

Heavily inspired by Short, friendly base32 slugs from timestamps by @brandur.

Install

Install with cargo by updating your Cargo.toml:

toml [dependencies] lexicoid = "*"

or with cargo-add you can run:

bash cargo add lexicoid

Usage

```rust use lexicoid::*;

// generates a lexicoid for the current timestamp println!("{}", lexicoid_now()); // gj7x3vc

// generates a lexicoid for a given unix timestamp (as u64) println!("{}", lexicoid(1654401676)); // gei4p52 ```

Use cases

Whenever you need simple and short ids that are lexicographically sorted based on the generation timestamp.

Examples:

Warning: since the resolution of the timestamps is per second, if you try to generate multiple ids in the same second, they will all be equal. This is not directly suitable for high frequency ID generation. But, if you need to adapt this approach to high frequency ID generation, you can always append the current number of milliseconds (or nanoseconds) to the generated ID.

Contributing

Everyone is very welcome to contribute to this project. You can contribute just by submitting bugs or suggesting improvements by opening an issue on GitHub.

License

Licensed under MIT License. © Luciano Mammino.