Closed wtdcode closed 2 months ago
Found this:
fn visit_str<E>(self, _v: &str) -> Result<Self::Value, E>
where
E: serde::de::Error,
{
// `from_reader` copies the bytes into a Vec before calling this
// method. Because the lifetime is unspecified, we can't borrow from it.
// As a result, we don't support `from_reader`.
Err(serde::de::Error::custom(
"Using serde_json::from_reader is not supported. Instead, buffer the reader contents into a string, as in alloy_json_abi::JsonAbi::load.",
))
}
Looks like I need to fix more code.
Give up.
Motivation
Fix #667
Solution
As title, use
Cow<'a, str>
to be compatible withserde_json::from_reader
PR Checklist
I don't see any possible breaking changes because previously it is not working. Besides, it shouldn't incur any performance penalty because from general
from_str
the data is still borrowed.