Being a newcomer to rmp, I needed some struggle to understand that I have to enable the with-serde feature of the rmpv crate for de/serializing data of type rmpv::Value. So far so good, e.g. now I can nicely convert a type into a Value with mpv::ext::to_value().
However, such Values are always created as Value::Arrays during serialization and there seems to be no way influencing this behavior. For serialization, usually there's a pair of functions where the default serializes into an array (e.g. rmp_serde::encode::to_vec) and there's a variant creating a map (e.g. rmp_serde::encode::to_vec_named). I cannot see anything similar for values, there's only to_value() without to_value_named() or anything similar.
Is there any way to serialize a type into a Value::Map with the current codebase? Would this require extra development efforts within the library? I even thought of customizing rmpv::ext::se::Serializer which seems to cause this behavior, but it's even private in the module.
Being a newcomer to
rmp, I needed some struggle to understand that I have to enable thewith-serdefeature of thermpvcrate for de/serializing data of typermpv::Value. So far so good, e.g. now I can nicely convert a type into aValuewithmpv::ext::to_value().However, such
Values are always created asValue::Arrays during serialization and there seems to be no way influencing this behavior. For serialization, usually there's a pair of functions where the default serializes into an array (e.g.rmp_serde::encode::to_vec) and there's a variant creating a map (e.g.rmp_serde::encode::to_vec_named). I cannot see anything similar for values, there's onlyto_value()withoutto_value_named()or anything similar.Is there any way to serialize a type into a
Value::Mapwith the current codebase? Would this require extra development efforts within the library? I even thought of customizingrmpv::ext::se::Serializerwhich seems to cause this behavior, but it's even private in the module.