-
Notifications
You must be signed in to change notification settings - Fork 88
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
UUID does not match #26
Comments
I have a some tricky solution, but it can be improved: #[derive(Debug)]
pub struct UUID(pub uuid::Uuid);
impl From<uuid::Uuid> for UUID {
fn from(value: uuid::Uuid) -> Self {
Self { 0: value }
}
}
fn uuid_to_bytes_be(id: &uuid::Uuid) -> [u8; 16] {
let bytes = id.as_bytes();
let mut result: [u8; 16] = [0; 16];
for i in 0..16 {
let multiplier = i / 8;
let j = i % 8;
let index = 8 * multiplier + 7 - j;
result[index] = bytes[i];
}
result
}
impl Serialize for UUID {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer
{
let bytes = uuid_to_bytes_be(&self.0);
serde::Serialize::serialize(&bytes, serializer)
}
} The idea is to move the bytes in the next order
After this you can pass |
Thanks @zryambus ! |
It obviously must be handled in this library, so I've reopened the issue.
What do you think about variants? |
I think that last two variants are pretty good. |
Published in |
The text was updated successfully, but these errors were encountered: