msgpack-rust icon indicating copy to clipboard operation
msgpack-rust copied to clipboard

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

Open godzie44 opened this issue 1 year ago • 0 comments

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);
}

godzie44 avatar Oct 25 '22 14:10 godzie44