speedrun_api/api/
query.rs1use async_trait::async_trait;
2
3use super::{ApiError, AsyncClient, Client};
4
5pub(crate) fn url_to_http_uri(url: url::Url) -> http::Uri {
6 url.as_str()
7 .parse::<http::Uri>()
8 .expect("failed to parse url::Url as http::Uri")
9}
10
11pub trait Query<T, C>
13where
14 C: Client,
15{
16 fn query(&self, client: &C) -> Result<T, ApiError<C::Error>>;
18}
19
20#[async_trait]
22pub trait AsyncQuery<T, C>
23where
24 C: AsyncClient,
25{
26 async fn query_async(&self, client: &C) -> Result<T, ApiError<C::Error>>;
28}