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
I noticed it when using postcard with erased-serde, but other formats may be susceptible to the same problem.
postcard::Error is an enum with a bunch of variants. It implements serde::de::Error, but the custom() method just ignores its msg argument and creates a postcard::Error::SerdeSerCustom.
Now, in erased-serde if there's an error during deserialization, it's passed through erase_de which calls serde::de::Error::custom(). So whatever information there was in the error is now lost.
My question is: is it technically a bug in postcard, and it should implement custom() without ignoring the message, even though it never uses this method itself? Or can it be fixed in erased-serde? The latter can be done by storing Box<dyn Any> in erased_serde::Error instead of Box<ErrorImpl>, and then downcasting it back in unerase_de(), but that would require either an .expect() (which I think should be safe, but does not look good in the code), or making unerase_de() fallible, passing the downcasting error to the deserializer (something that will never happen unless there's a bug in the code).
The text was updated successfully, but these errors were encountered:
I noticed it when using
postcard
witherased-serde
, but other formats may be susceptible to the same problem.postcard::Error
is an enum with a bunch of variants. It implementsserde::de::Error
, but thecustom()
method just ignores itsmsg
argument and creates apostcard::Error::SerdeSerCustom
.Now, in
erased-serde
if there's an error during deserialization, it's passed througherase_de
which callsserde::de::Error::custom()
. So whatever information there was in the error is now lost.My question is: is it technically a bug in
postcard
, and it should implementcustom()
without ignoring the message, even though it never uses this method itself? Or can it be fixed inerased-serde
? The latter can be done by storingBox<dyn Any>
inerased_serde::Error
instead ofBox<ErrorImpl>
, and then downcasting it back inunerase_de()
, but that would require either an.expect()
(which I think should be safe, but does not look good in the code), or makingunerase_de()
fallible, passing the downcasting error to the deserializer (something that will never happen unless there's a bug in the code).The text was updated successfully, but these errors were encountered: