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

`from_read` issue constructing a generic `Deserializer`

Open tgross35 opened this issue 1 year ago • 1 comments

I am trying to construct a Deserializer for use with serde_transcode, but it is failing:

let mut deserializer: rmp_serde::Deserializer<_> = rmp_serde::from_read(input).unwrap();

input has the type Box<dyn Read>. The converse does seem to work:

let mut serializer = rmp_serde::Serializer::new(output);

What is the correct construction?

tgross35 avatar Jan 07 '23 02:01 tgross35

I am not sure, but this might relate to #306

If that is the case, could something like serde_json's `IoRead' be added to this crate? It seems like this is the wrapper they use to buffer input.

As an example, this works:

let mut deserializer: serde_json::Deserializer<serde_json::de::IoRead<Box<dyn Read>>> =
    serde_json::Deserializer::from_reader(input);

tgross35 avatar Jan 07 '23 02:01 tgross35