Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use crate::error::TPError;
- use reqwest::Url;
- use serde::Deserialize;
- pub trait FromQuery<'de>: Sized
- {
- type RecvType: Deserialize<'de> + Into<Self>;
- fn api_url(query: &str) -> Result<Url, TPError>;
- fn from_query(query: &str) -> Result<Self, TPError>
- {
- Ok(reqwest::get(Self::api_url(query)?)?
- .json::<Self::RecvType>()
- .expect("Failed to parse API response. Did the external API change?")
- .into())
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement