Skip to content

✨ feat(mq-lang): add uuid, uuid_v4, and uuid_v7 builtin functions#1965

Merged
harehare merged 2 commits into
mainfrom
feat/builtin-uuid
Jul 2, 2026
Merged

✨ feat(mq-lang): add uuid, uuid_v4, and uuid_v7 builtin functions#1965
harehare merged 2 commits into
mainfrom
feat/builtin-uuid

Conversation

@harehare

@harehare harehare commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Summary

Adds random UUID generation. uuid/uuid_v4 produce RFC 4122 version 4 UUIDs; uuid_v7 produces RFC 9562 version 7 (time-ordered, sortable) UUIDs, useful for database primary keys and log IDs.

Randomness is delegated to the rand crate (OS-seeded via getrandom) through a small internal random module, rather than a hand-rolled generator, so output isn't predictable from call time. wasm32 support is wired up via getrandom's wasm_js feature, verified against both mq-lang and mq-wasm with cargo check --target wasm32-unknown-unknown.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor
  • 📝 Documentation
  • ⚡ Performance
  • ✅ Test
  • 📦 Build / dependencies
  • 👷 CI

Checklist

  • I ran cargo fmt and cargo clippy and addressed any warnings
  • I ran just test-all and all tests pass
  • I added or updated tests covering this change
  • I updated relevant documentation (/docs, crate README.md) if needed
  • I added a changelog entry if this is a user-facing change

Additional Context

Adds random UUID generation. `uuid`/`uuid_v4` produce RFC 4122 version 4
UUIDs; `uuid_v7` produces RFC 9562 version 7 (time-ordered, sortable)
UUIDs, useful for database primary keys and log IDs.

Randomness is delegated to the `rand` crate (OS-seeded via `getrandom`)
through a small internal `random` module, rather than a hand-rolled
generator, so output isn't predictable from call time. wasm32 support
is wired up via getrandom's `wasm_js` feature, verified against both
mq-lang and mq-wasm with `cargo check --target wasm32-unknown-unknown`.
@codspeed-hq

codspeed-hq Bot commented Jul 2, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing feat/builtin-uuid (413d7e6) with main (e3d21e5)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (83cdd2c) during the generation of this report, so e3d21e5 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Replace the hand-rolled RFC 4122/9562 byte-formatting and version/variant
bit-twiddling with the `uuid` crate's `Uuid::new_v4`/`Uuid::now_v7`. Drops
the now-unused internal `random` module and its `rand` dependency; the
`uuid` crate sources its own CSPRNG (via getrandom on native, and the `js`
feature backed by wasm-bindgen on wasm32-unknown-unknown).
@harehare harehare merged commit d3f6785 into main Jul 2, 2026
11 of 13 checks passed
@harehare harehare deleted the feat/builtin-uuid branch July 2, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant