Closed hawkw closed 2 years ago
lgtm.
As for the CI (codegen) failure, I implemented a way to automatically fix that (https://github.com/rust-lang/futures-rs/pull/2562), but forgot to port it to this repository. I will open a PR later.
@taiki-e great, happy to rebase this once CI is sorted out!
@hawkw: Filed #90 to fix CI issue.
Currently,
valuable-serde
handlesValue::Error
variants incorrectly. Whenvaluable-serde
encounters aValue::Error
, it returns the error immediately as a serialization error: https://github.com/tokio-rs/valuable/blob/1fc2ad50fcae7fc0da81dc40a385c235636ba525/valuable-serde/src/lib.rs#L267This is not correct. If a
serde
serializer returns an error, this means something has gone wrong while serializing a value. Returning an error makes the serialization fail. However, this is not whatvaluable
'sValue::Error
means.Value::Error
represents that we are recording a value which happens to be anError
, not that something went wrong while recording the value. This means thatvaluable-serde
will currently return anError
(indicating that serialization failed) any time it attempts to record anError
value, and serialization will fail.This commit changes
valuable-serde
to record the error using itsDisplay
implementation, usingserde
'scollect_str
method. Now,Error
s will be serialized by recording their messages as a string, rather than causing the serialization to fail.Using
collect_str
allows the serializer to write the display representation to its own internal buffer, rather than having to format the error to a temporaryString
beforehand.Fixes #88