3Hren / msgpack-rust

MessagePack implementation for Rust / msgpack.org[Rust]
MIT License
1.17k stars 130 forks source link

serde::to_vec(rmpv::Value) works unexpected #320

Open godzie44 opened 2 years ago

godzie44 commented 2 years ago

Hi! Looks like rmp_serde::to_vec works not properly for rmpv::Value with map inside it. I'm expected that result is encoded message pack vector, but result is a map. For example:

#[test]
fn serialize_value_as_map() {
    let value = rmpv::Value::Map(vec![
        (rmpv::Value::from("a"), rmpv::Value::from(1)),
        (rmpv::Value::from("b"), rmpv::Value::from(2)),
    ]);
    let encoded = rmp_serde::to_vec(&value).unwrap();

    assert_eq!(vec![130, 161, 97, 1, 161, 98, 2], encoded);
}