bento_kit/id/mod.rs
1//! ID generation — Rust port of [`du-node-utils/lib/id.js`](https://github.com/imcooder/du-node-utils/blob/main/lib/id.js).
2//!
3//! The function names track the Node original (snake-cased to match Rust
4//! conventions). UUIDs and nanoids are exposed on top as Rust-side
5//! conveniences.
6//!
7//! ## Node parity
8//!
9//! | Node | Rust |
10//! |-------------------------------|------------------------------------|
11//! | `id.makeUUID(false)` | [`uuid_v4`] |
12//! | `id.makeUUID(true)` | [`uuid_v4_simple`] |
13//! | `id.randomInt(min, max)` | [`random_int`] |
14//! | `id.randomString(len)` | [`random_string`] |
15//! | `id.makeUidPostfix()` | [`make_uid_postfix`] |
16//! | `id.makeUserId(a, u, c)` | [`make_user_id`] |
17//! | `id.parseUserid(s)` | [`parse_user_id`] |
18//! | `id.makeDbKey(uid)` | [`make_db_key`] |
19//! | `id.setSessionPrefix(p)` | [`set_session_prefix`] |
20//! | `id.generateSessionId()` | [`generate_session_id`] |
21//!
22//! Rust additions (no Node equivalent):
23//!
24//! - [`uuid_v7`] / [`uuid_v7_simple`] — time-ordered UUIDs.
25//! - [`nanoid`] / [`nanoid_with_len`] / [`nanoid_with_alphabet`] — short URL-safe IDs.
26
27mod nanoid;
28mod random;
29mod session;
30mod uuid;
31
32pub use self::nanoid::{nanoid, nanoid_with_alphabet, nanoid_with_len, DEFAULT_NANOID_LEN};
33pub use self::random::{random_int, random_string};
34pub use self::session::{
35 generate_session_id, make_db_key, make_uid_postfix, make_user_id, parse_user_id,
36 set_session_prefix, UserId,
37};
38pub use self::uuid::{uuid_v4, uuid_v4_simple, uuid_v7, uuid_v7_simple};