Skip to content

Conversation

MavethGH
Copy link

This PR adds a new feature (bincode2) that when enabled, derives Encode and Decode for Uuid. See this section of the migration guide for bincode 2.

@KodrAus
Copy link
Member

KodrAus commented Mar 23, 2025

Hi @MavethGH 👋 I’m not familiar with bincode 2 yet. If bincode 2.x is expected to produce compatible bytes as 1.x then we should make sure we serialize to the same binary when using serde + bincode 1.x, and when using bincode 2.x.

@MavethGH
Copy link
Author

If bincode 2.x is expected to produce compatible bytes as 1.x then we should make sure we serialize to the same binary when using serde + bincode 1.x, and when using bincode 2.x.

The bytes will not be the same, since serde includes the length of the array, while bincode 2.x doesn't since it's a fixed-size array. However, bincode 2.x can still deserialize a Uuid serialized that way by using Compat and config::legacy().

@KodrAus
Copy link
Member

KodrAus commented Mar 24, 2025

It looks like bincode 2.x does include the length of the array if we serialize it as a &[u8] instead of as [u8; 16], which is how we do it with serde and bincode 1.x just because that's the API serde gives us.

cc @ZoeyR @VictorKoenders who look like they might be maintaining bincode now, is there a general expectation that if you already support bincode 1.x that you'll maintain an equivalent encoding in bincode 2.x? Or should users expect there to be differences?

@ZoeyR
Copy link

ZoeyR commented Mar 24, 2025

If at all possible the encodings should be equivalent.

@KodrAus
Copy link
Member

KodrAus commented Mar 24, 2025

Thanks @ZoeyR. In that case, I think we should implement Encode and Decode manually, and add a test to ensure equivalence with serde + bincode 1.x. We don't necessarily need to depend on serde and bincode 1.x to do it, we can just use a pre-serialized buffer.

@francisbr
Copy link

I worked a a simple manual implementation of Encode & Decode
#821

@MavethGH
Copy link
Author

@francisbr Thanks!

@MavethGH
Copy link
Author

Going to close this now in that case.

@MavethGH MavethGH closed this Mar 27, 2025
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.

4 participants