New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serialises UUID as [u8:16] #331
Conversation
* This commit adds a feature `dense_serde` which enables serialization and deserialization of a Uuid as a [u16; 8]
5155759
to
7d1741c
Compare
Thanks @Redrield! From the discussion on #329, using a feature flag here doesn't actually save us from potential breakage. It looks like we want to keep the output of One way we could do this in a backwards compatible way that users properly opt into would be to convert your new |
@KodrAus newtypes? |
@kinggoesgaming I think a newtype isn't a natural solution here. It's really the same type, just serialized in a different way, and it may even depend on the context what serialization to use. I like the suggestion to use free functions for use with serde attributes, since it makes the intention of client code immediately obvious. |
I'm thinking add a module that can be used with |
What do you think of |
note |
Ok, so we could do |
Rewritten to use serde attributes for dense serialization under uuid::adapter::compact |
src/adapter/compact.rs
Outdated
u: &Uuid, | ||
serializer: S, | ||
) -> Result<S::Ok, S::Error> { | ||
println!("sereeeeeeeeealize"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uhmm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug messages, i'll take those out, whoops!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a // TODO just to be sure :)
we have a bot that marks TODO comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wdym? Removed them in b1b2efe
bors r+ |
331: Serialises UUID as [u8:16] r=kinggoesgaming a=Redrield **I'm submitting a** feature # Description Adds the ability to serialize a Uuid as a [u8; 16]. Functionality is behind the `dense_serde` feature. the `serde` feature continues to serialize as a &[u8]. Both features serialize strings identically # Tests A new test module for the feature was added, mirroring the tests of the `serde` feature (with modifications to expected tokens where necessary) # Related Issue(s) closes #329 Co-authored-by: Redrield <redrield@gmail.com>
I'm submitting a feature
Description
Adds the ability to serialize a Uuid as a [u8; 16]. Functionality is behind the
dense_serde
feature. theserde
feature continues to serialize as a &[u8]. Both features serialize strings identicallyTests
A new test module for the feature was added, mirroring the tests of the
serde
feature (with modifications to expected tokens where necessary)Related Issue(s)
closes #329