timeid
A compact, time-based unique ID generator with SQLite tracking.
Each ID encodes the current Unix timestamp using a custom base character set and ensures uniqueness by storing used IDs in a local SQLite database (~/.timeid.sqlite by default).
๐ฆ Features
- ๐ Guarantees uniqueness by checking past IDs in a local database.
- ๐ Easily decodes IDs back to human-readable timestamps.
- ๐ Optional memo and tag can be saved with each ID.
- ๐พ Uses SQLite under the hood for lightweight local persistence.
๐ง Usage
Add to your Cargo.toml:
[]
= "0.0.1"
Then use in your code:
use TimeId;
๐ Resetting the Database
You can reset the SQLite database:
reset?;
This deletes and recreates the default ~/.timeid.sqlite.
๐งช Testing
To test:
๐ Storage Path
By default, the SQLite file is stored at:
- macOS/Linux:
~/.timeid.sqlite - Windows:
%USERPROFILE%/.timeid.sqlite
You can override the path by passing a custom one to reset() or modifying the internal init() function.
๐ License
MIT License
โจ Author
Nick (@loyoming)