Migrating serde -> miniserde

I am trying to reduce the bloat, as I only read json to fill one fairly simple struct. However, I get a problem with reqwest client compatibility.
More precisely, the following code fails on .json::<PriceStruct>()
with error:
error[E0277]: the trait bound for<'de> structs::PriceStruct: serde::de::Deserialize<'de> is not satisfied`
Is there any way to get round this with miniserde?

let resp = client
	   .get(&uri)
		.send()
		.await.with_context(|| format!("{}: getprice client-request failed at {},{}",file!(),line!(),column!()))?
		.json::<PriceStruct>()
		.await.with_context(|| format!("{}: getprice failed to parse json at {},{}",file!(),line!(),column!()))?;   

If you want to use some other library than serde for deserialization, you should first read the response into memory with bytes, and then use your deserialization library on the resulting slice.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.