How can the error be resolved?
FetchService get data structure in JSON format
#[derive(Debug, Deserialize)]
pub struct Data {
value: String,
}
pub enum Message {
FetchReady(Result<Data, anyhow::Error>),
}
let request = Request::get(String::from("/data.json"))
.body(Nothing)
.unwrap();
let fetch_callback =
self.link
.callback(|response: Response<Json<Result<Data, anyhow::Error>>>| {
let (meta, Json(data)) = response.into_parts();
if meta.status.is_success() {
Message::FetchReady(data)
} else {
Message::FetchReady(Err(anyhow!(
"{}: error getting file",
meta.status
)))
}
});
let task = self.fetch_service.fetch(request, fetch_callback);
~~~~~~~~~~~~~
the trait bound yew::format::json::Json<std::result::Result<my::form::Data, anyhow::Error>>: std::convert::From<std::result::Result<std::string::String, failure::error::Error>> is not satisfied
the trait std::convert::From<std::result::Result<std::string::String, failure::error::Error>> is not implemented for yew::format::json::Json<std::result::Result<my::form::Data, anyhow::Error>>
help: the following implementations were found:
It seems like failures Error type is part of yews public API. You can't just replace failure with anyhow in the fetch service examples.
To be a little more precise, the Text type seems to be what's causing the issue here.
@kellytk which version (or branch) of yew are you using? We recently changed from failure to anyhow on master so this might be tripping you up
Solved over on Gitter: https://gitter.im/yewframework/Lobby?at=5e3c302bea9ba00b84b64a99