SerializeDict and friends make instances not usable for other data formats
I am interested in fixing this myself, but would like to discuss first.
When I use DeserializeDict
, and then use the Deserialize instance for e.g. JSON, due to the implementation of DeserializeDict I get JSON full of references to zbus:
{"update_time":{"zvariant::Value::Signature":"s","zvariant::Value::Value":"2021-07-14T20:04:01Z"},"timestamp":{"zvariant::Value::Signature":"s","zvariant::Value::Value":"2021-07-14T20:04:02.324114279Z"},"observation":{"zvariant::Value::Signature":"a{sv}","zvariant::Value::Value":{"date":{"zvariant::Value::Signature":"s","zvariant::Value::Value":"2021-07-14T20:04:01Z"}...
I have a proposal that will address this and simultaneously allow dict-style users of zbus to use all serde macros. The proposal is to have the zbus serializer/deserializer switch whether they work in "dict" mode or "typed" mode based on a new method to be added to the type trait,
fn serialization_mode() -> SerializationMode;
enum SerializationMode {
Typed,
Dict,
}
Alternatively, a separate serializer (to Value objects potentially rather than directly to the binary type) could be used.
This would allow the serde instances to all be cross-format and also get support for all the attributes for free.
I think this would be EASIER than adding all the attributes to the *Dict forms of the macros (especially since I'd like to make the change and this would be better for my purposes :-) )