Skip to content

Add support for uuid::Uuid#34

Merged
caibear merged 14 commits intoSoftbearStudios:mainfrom
vnghia:uuid
Aug 13, 2025
Merged

Add support for uuid::Uuid#34
caibear merged 14 commits intoSoftbearStudios:mainfrom
vnghia:uuid

Conversation

@vnghia
Copy link
Copy Markdown
Contributor

@vnghia vnghia commented Aug 24, 2024

Close #33

@finnbear
Copy link
Copy Markdown
Member

Thanks for the PR! Here are a few thoughts:

  • I'm in favor of accepting this impl if uuid doesn't want to derive it 👍
  • The binary representation you chose differs from Add bitcode support uuid-rs/uuid#739. Theirs encodes a [u8; 16] whereas yours encodes a u128. There may be an alignment difference and, for that and other reasons, performance difference. I'll personally benchmark this before merging.
  • I'd like to use the strategy I used in Add support for std::net::{*Addr*} #30 to avoid writing custom code each time we need to encode one type in terms of another. That's not reviewed/merged yet so this will have to wait.

@finnbear finnbear added the enhancement New feature or request label Aug 25, 2024
@finnbear finnbear changed the title feat: add support for encode/decode uuid feat: add support for encode/decode uuid::Uuid Aug 25, 2024
@finnbear finnbear changed the title feat: add support for encode/decode uuid::Uuid Add support for uuid::Uuid Aug 25, 2024
@vnghia
Copy link
Copy Markdown
Contributor Author

vnghia commented Sep 13, 2024

Hi @finnbear, I use the new approach as you mentioned. Essentially just move ConvertFrom related code to a new mod and use that for encode/decode uuid. I let you decide which binary representation to go (u128 vs [u8;16]) but I think it is done on my side.

@finnbear
Copy link
Copy Markdown
Member

Thanks for this! Regarding the encoding process, @caibear has recently started experimenting with using uuid's support for bytemuck to make it more efficient than what I suggested. I'll keep you updated :)

@retorted
Copy link
Copy Markdown

Any updates on this? Anything contributors can do to help?

UUID support would be really useful! 🙏

@finnbear
Copy link
Copy Markdown
Member

Good to know multiple people want it. This increases the priority.

@caibear
Copy link
Copy Markdown
Collaborator

caibear commented Aug 12, 2025

@finnbear if the representation can be switched to [u8; 16] to avoid bad u128 codegen and the ConvertFrom encoder can be removed (is already on main) I think this can be merged.

Edit: And also try to limit the scope of the changes to Cargo.toml and uuid.rs specificically

impl_convert!(uuid::Uuid, u128);

and

#[cfg(feature = "uuid")]
test!(uuid::Uuid::new_v4(), uuid::Uuid);

@caibear caibear enabled auto-merge (squash) August 12, 2025 23:48
@caibear caibear merged commit dc353a9 into SoftbearStudios:main Aug 13, 2025
3 checks passed
@finnbear finnbear mentioned this pull request Jan 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for UUID

4 participants