Skip to content

[feat] Ordering feature for bson serializationย #490

@mahmoud-moursy

Description

@mahmoud-moursy

I was trying to cryptographically sign some BSON documents using the dryoc crate, and noticed that, sometimes my tests would pass, other times they would somehow fail!? And when I made some seemingly random changes to the code, it would start working again!?

It turns out the root cause was that, when I was serializing the same data, it was not always in the same order, causing the signature to be different! ๐Ÿ˜ฎ

I guess that's on me for trying this with an unstructured data format, but it would be nice to have a feature that automatically sorts entries. I currently hacked together a to_sorted function that sorts the entries using &str's handy built-in Cmp.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions