I need more info. Can you post the full error messages as reported by cargo build? For example, that would tell me which lines caused the errors you posted.
error[E0308]: mismatched types
--> src/wallet/api.rs:96:70
|
96 | let err = serde_json::from_slice::<PoolErrorWrapper>(e)?;
| ^ expected `&[u8]`, found struct `wallet::api::PoolError`
error[E0277]: `?` couldn't convert the error to `wallet::api::FetchError`
--> src/wallet/api.rs:96:72
|
96 | let err = serde_json::from_slice::<PoolErrorWrapper>(e)?;
| ^ the trait `std::convert::From<serde_json::error::Error>` is not implemented for `wallet::api::FetchError`
|
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
= help: the following implementations were found:
<wallet::api::FetchError as std::convert::From<reqwest::error::Error>>
<wallet::api::FetchError as std::convert::From<wallet::api::PoolError>>
= note: required by `std::convert::From::from`
That’s at least one of the errors. And maybe the other. That second code sample is the same code I gave you in another post.
I know when learning Rust it can be hard to understand what’s going on, but one recommendation is to pay attention to the types. If you don’t know what type variable e is, you can put this in the code let () = e; and the compiler will complain that you’re assigning the variable to the wrong type but in the process it will tell you the type of e. And then at times it just turns into taking the type you have and the type you want, and trying to figure out what gets you there.
In this case e should already be type PoolError so you can pass it directly to FetchError::PoolError. There might be a new error that pops up after that but that should get you closer.
one thing i don't understand is that.
when the http data be {code:400,msg:"pool err"}, so as we know it can't be serizial as MiningInfoResponse, it will throw out an serialize error, but do we need to re serialize it , such as json<HashMap<String,String>>(e) ??? if we not parse it, the e will be err:{code:400,msg:"pool err"}, just be a bytes?? so i am really confused
#[serde(untamed)] tells serde to try the first variant MiningInfoResponse in the enum JsonResult and if it fails try the next variant PoolError . This will only work if the fields for a successful response are different from those if there an error. If you share an example of both a successful and unsuccessful response and what your definition of MiningInfoResponse is, it would make it easier to help with the issue.