alchemy_api/cores/query.rs
1use super::client::Client;
2use async_trait::async_trait;
3use http::Uri;
4use url::Url;
5
6/// Convert url::Url to http::Uri
7pub fn url_to_http_uri(url: Url) -> Uri {
8 url.as_str()
9 .parse::<Uri>()
10 .expect("failed to parse a url::Url as an http::Uri")
11}
12
13/// A trait which represents an asynchronous query which may be made to a client.
14#[async_trait]
15pub trait Query<T, C>
16where
17 C: Client,
18{
19 /// Perform the query asynchronously against the client.
20 async fn query(&self, client: &C) -> anyhow::Result<T>;
21}