Advertisement
Guest User

Untitled

a guest
Jul 14th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 1.37 KB | None | 0 0
  1. use crate::error::TPError;
  2. use reqwest::Url;
  3. use serde::Deserialize;
  4.  
  5. pub trait FromQuery<'de>: Sized
  6. {
  7.   type RecvType: Deserialize<'de> + Into<Self>;
  8.  
  9.     fn api_url(query: &str) -> Result<Url, TPError>;
  10.  
  11.     fn from_query(query: &str) -> Result<Self, TPError>
  12.     {
  13.         Ok(reqwest::get(Self::api_url(query)?)?
  14.             .json::<Self::RecvType>()
  15.             .expect("Failed to parse API response. Did the external API change?")
  16.             .into())
  17.     }
  18. }
  19.  
  20. // error[E0277]: the trait bound `for<'de> <Self as traits::from_url::FromQuery<'de>>::RecvType:
  21. // api::area_search::_IMPL_SERIALIZE_FOR_TestJson::_serde::Deserialize<'de>` is not satisfied
  22. //  --> server/src/traits/from_url.rs:14:14
  23. //    |
  24. // 14 |             .json::<Self::RecvType>()
  25. //    |              ^^^^ the trait `for<'de> api::area_search::_IMPL_SERIALIZE_FOR_TestJson::_serde::Deserialize<'de>` // is not implemented for `<Self as traits::from_url::FromQuery<'de>>::RecvType`
  26. //    |
  27. //    = help: consider adding a `where for<'de> <Self as traits::from_url::FromQuery<'de>>::RecvType:
  28. // api::area_search::_IMPL_SERIALIZE_FOR_TestJson::_serde::Deserialize<'de>` bound
  29. //    = note: required because of the requirements on the impl of
  30. // `api::area_search::_IMPL_SERIALIZE_FOR_TestJson::_serde::de::DeserializeOwned` for `<Self as
  31. // traits::from_url::FromQuery<'de>>::RecvType`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement