3Hren / 3Hren/msgpack-rust

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

Open
#190 0 comments 7 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.4k
Forks
162
PR merge metrics
No merged PRs in 30d

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 `Value`s are always created as `Value::Array`s 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.