Skip to content

Serializing custom types into Value, allow named Map instead of Array representation #190

Open
@izolyomi

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions