The serde::private::de::Content does not impl Deserializer itself, rather a separate ContentDeserializer type implements it. This allows ContentDeserializer to be used insideDeserialize impls, since Deserialize impls must be generic on the Error type.
The same cannot be done with serde_value::Value since it impls Deserializer on itself with a fixed Error = serde_value::DeserializerError type.
It would be useful to have a separate
struct ValueDeserializer<E: serde::de::Error>(Value, PhantomData<E>);
impl<'de, E: serde::de::Error> Deserialize<'de> for ValueDeserializer<E> {
type Error = E;
// same as current Value impl, except for visit_seq and visit_map
// that need to wrap the value in Self first
}
Content's Deserializer impl could then forward to ContentDeserializer<serde_value::DeserializerError> to maintain backward compatibility.
The
serde::private::de::Content
does not implDeserializer
itself, rather a separateContentDeserializer
type implements it. This allowsContentDeserializer
to be used insideDeserialize
impls, sinceDeserialize
impls must be generic on theError
type.The same cannot be done with
serde_value::Value
since it implsDeserializer
on itself with a fixedError = serde_value::DeserializerError
type.It would be useful to have a separate
Content
'sDeserializer
impl could then forward toContentDeserializer<serde_value::DeserializerError>
to maintain backward compatibility.