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
Hello, I noted a regression when using rmp_serde 1.2.0 and over, when trying to read from a deserializer that had an error
consider the following script:
use std::fmt;use rmp_serde;use serde::Deserialize;use serde::de::{Deserializer,Visitor};// a sample struct that expects an array with one i8 at the end// to simulate error recoverystructContinueTillI8(i8);impl<'de>Deserialize<'de>forContinueTillI8{fndeserialize<D>(deserializer:D) -> Result<Self,D::Error>whereD:Deserializer<'de>,{structContinueTillI8Visitor;impl<'de>Visitor<'de>forContinueTillI8Visitor{typeValue = ContinueTillI8;fnexpecting(&self,formatter:&mut fmt::Formatter) -> fmt::Result{
formatter.write_str("array that has one i8 at the end")}fnvisit_seq<A>(self,mutseq:A) -> Result<Self::Value,A::Error>whereA: serde::de::SeqAccess<'de>,{loop{match seq.next_element(){Ok(Some(i)) => {returnOk(ContinueTillI8(i));}Err(e) => {println!("discraded element with err: {:?}", e);}Ok(None) => {returnErr(serde::de::Error::custom("No i8 found"));}}}}}
deserializer.deserialize_any(ContinueTillI8Visitor)}}fnmain(){let data = ("hi",8);let raw_data = rmp_serde::to_vec(&data).unwrap();let value:ContinueTillI8 = rmp_serde::from_slice(&raw_data[..]).unwrap();println!("{:?}", value.0);// should print 8}
with rmp_serde 1.2.0 and up, I get the following result:
discarded element with err: TypeMismatch(FixStr(2))
104
with 1.1.1, we get the expected output of 8
discarded element with err: Syntax("invalid type: string \"hi\", expected i8")
8
this is likely due to rmp_serde not consuming the FixStr(2)'s actual value after detecting it is not an i8, leaving the deserailizer in an invalid state
The text was updated successfully, but these errors were encountered:
Hello, I noted a regression when using rmp_serde 1.2.0 and over, when trying to read from a deserializer that had an error
consider the following script:
with rmp_serde 1.2.0 and up, I get the following result:
with 1.1.1, we get the expected output of 8
this is likely due to rmp_serde not consuming the
FixStr(2)
's actual value after detecting it is not an i8, leaving the deserailizer in an invalid stateThe text was updated successfully, but these errors were encountered: