To reproduce (num-format v0.4.4 + bincode v1.3.3):
fn main() {
// Create an empty `Buffer`.
let mut buf = num_format::Buffer::new();
// Serialize to bytes.
let ser: Vec<u8> = bincode::serialize(&buf).unwrap();
// Attempt to deserialize. This panics.
let de: num_format::Buffer = bincode::deserialize(&ser).unwrap();
}
Error message:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Custom("invalid type: byte array, expected bytes of maximum length 191")', src/main.rs:7:70
Regular formats (JSON, TOML, etc) will (de)serialize correctly, so I believe it has something to do with the binary formats and the custom serde implementation on Buffer.
The
Buffer
type will always fail to deserialize when using it withserde
and binary formats, the ones I've tested:bincode
messagepack
BSON
postcard
To reproduce (
num-format v0.4.4
+bincode v1.3.3
):Error message:
Culprit code is most likely here.
Regular formats (
JSON
,TOML
, etc) will (de)serialize correctly, so I believe it has something to do with the binary formats and the customserde
implementation onBuffer
.