| Crates.io | timeid |
| lib.rs | timeid |
| version | 0.0.1 |
| created_at | 2025-06-01 01:32:19.623157+00 |
| updated_at | 2025-06-01 01:32:19.623157+00 |
| description | A simple crate to generate unique, timestamp-based IDs with memo/tag support stored in local SQLite |
| homepage | |
| repository | https://github.com/nicklawman/timeid |
| max_upload_size | |
| id | 1696825 |
| size | 16,939 |
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).
Add to your Cargo.toml:
[dependencies]
timeid = "0.0.1"
Then use in your code:
use timeid::TimeId;
fn main() -> rusqlite::Result<()> {
let id = TimeId::gen()?; // Generate a new ID
println!("Generated ID: {}", id);
let readable = TimeId::parse(&id); // Parse ID back to datetime
println!("Parsed: {}", readable);
let count = TimeId::status()?; // Check total generated
println!("Stored rows: {}", count);
Ok(())
}
You can reset the SQLite database:
TimeId::reset(None)?;
This deletes and recreates the default ~/.timeid.sqlite.
To test:
cargo test -- --nocapture
By default, the SQLite file is stored at:
~/.timeid.sqlite%USERPROFILE%/.timeid.sqliteYou can override the path by passing a custom one to reset() or modifying the internal init() function.
MIT License
Nick (@loyoming)