You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The serde implementation in rmp-serde encodes enum variants as a single-element mapping with the variant's name as a key; in contrast, rmpv's serde implementation encodes enum variants as a two-element array with the variant index as the first element.
Example:
use serde::{Deserialize,Serialize};#[derive(Serialize,Deserialize)]pubenumFoo{Bar(String),}fnmain(){let bar = Foo::Bar(String::from("Heya lol"));let encoded_bin = rmp_serde::encode::to_vec(&bar).unwrap();for b in&encoded_bin {print!("{b:02x}");}println!();let decoded_val = rmpv::decode::read_value::<&[u8]>(&mut encoded_bin.as_ref()).unwrap();println!("{decoded_val:?}");let encoded_val = rmpv::ext::to_value(&bar).unwrap();println!("{encoded_val:?}");}
Either of these encodings is reasonable on its own, but it would seem that the two implementations should agree by default.
Relatedly, as noted in #323, the documentation incorrectly states that the default configuration in rmp-serde serializes enum variants as integer indices.
The text was updated successfully, but these errors were encountered:
The
serde
implementation inrmp-serde
encodes enum variants as a single-element mapping with the variant's name as a key; in contrast,rmpv
's serde implementation encodes enum variants as a two-element array with the variant index as the first element.Example:
The above code outputs the following:
Either of these encodings is reasonable on its own, but it would seem that the two implementations should agree by default.
Relatedly, as noted in #323, the documentation incorrectly states that the default configuration in
rmp-serde
serializes enum variants as integer indices.The text was updated successfully, but these errors were encountered: