alchemy_api/cores/client.rs
1use async_trait::async_trait;
2use bytes::Bytes;
3use http::request::Builder as RequestBuilder;
4use http::Response;
5use url::Url;
6
7/// A trait representing a client which can communicate with a [Alchemy API] instance via REST.
8#[async_trait]
9pub trait Client {
10 /// Get the URL for the endpoint for the client.
11 ///
12 /// This method adds the hostname for the client's target instance.
13 fn endpoint(&self, endpoint: &str) -> anyhow::Result<Url>;
14
15 /// Send a REST query asynchronously.
16 async fn send(&self, request: RequestBuilder, body: Vec<u8>)
17 -> anyhow::Result<Response<Bytes>>;
18}