stratisd icon indicating copy to clipboard operation
stratisd copied to clipboard

Serialization of UUIDs

Open mulkieran opened this issue 7 years ago • 3 comments

See: https://github.com/rust-lang-nursery/uuid/issues/90.

I don't think this change causes a problem, but we should review what we do wrt. it and update our docs accordingly.

mulkieran avatar Jan 26 '18 23:01 mulkieran

To match the spec's definition of serialized uuids we will need to do something here, since serde puts dashes in uuids by default.

agrover avatar Mar 14 '18 20:03 agrover

We should consider whether following the spec will make our lives harder to no advantage before we go further.

Also, I'm not sure that serde puts dashes in uuids by default anymore, I think it uses the raw numbers.

mulkieran avatar Mar 15 '18 13:03 mulkieran

There are dashes in our JSON metadata's uuids, which bothers me because I'd really like to be consistently no-hyphens everywhere (cmdline, D-Bus API, internally).

The dashes are because of how uuid::Uuid implements Serializable, and we're using these in our code with just type aliases. We could override default serialization in serde (using "serialize_with") for simple uuid struct members but I ran into trouble overriding e.g. Option<Vec<(Uuid, Sectors, Sectors)>> members.

Or, we could change serde struct definitions to String from Uuid, and then convert manually in/out. It's a +80 line patch. Not worth it.

So I'm giving up on total consistency for the moment. We should strive to represent UUIDs externally always as non-hyphenated, and if we someday accept a uuid parameter only accept non-hyphenated, but our dark secret can be uuids are hyphenated in our json metadata :man_shrugging:

agrover avatar Aug 08 '18 23:08 agrover