ATrium XRPC Client
This library provides clients that implement the XrpcClient defined in atrium-xrpc. To accommodate a wide range of use cases, four feature flags are provided to allow developers to choose the best asynchronous HTTP client library for their project as a backend.
Features
reqwest-native(default)reqwest-rustlsisahcsurf
Usage examples are provided below.
reqwest-native and reqwest-rustls
If you are using tokio as your asynchronous runtime, you may find it convenient to utilize the reqwest backend with this feature, which is a high-level asynchronous HTTP Client. Within this crate, you have the choice of configuring reqwest with either reqwest/native-tls or reqwest/rustls-tls.
[]
= "*"
To use the reqwest::Client with the rustls TLS backend, specify the feature as follows:
[]
= { = "*", = false, = ["reqwest-rustls"]}
In either case, you can use the ReqwestClient:
use ReqwestClient;
You can also directly specify a reqwest::Client with your own configuration:
[]
= { = "*", = false }
= { = "0.11.22", = false, = ["rustls-tls"] }
use ReqwestClientBuilder;
For more details, refer to the reqwest documentation.
isahc
The reqwest client may not work on asynchronous runtimes other than tokio. As an alternative, we offer the feature that uses isahc as the backend.
[]
= { = "*", = false, = ["isahc"]}
use IsahcClient;
Similarly, you can directly specify an isahc::HttpClient with your own settings:
[]
= { = "*", = false, = ["isahc"]}
= "1.7.2"
use IsahcClientBuilder;
use Configurable;
For more details, refer to the isahc documentation.
surf
For cases such as using rustls with asynchronous runtimes other than tokio, we also provide a feature that uses surf built with async-std as a backend.
Using DefaultClient with surf is complicated by the various feature flags. Therefore, unlike the first two options, you must always specify surf::Client when creating a client with this module.
[]
= { = "*", = false, = ["surf"]}
= { = "2.3.2", = false, = ["h1-client-rustls"] }
use SurfClient;
Using http_client and its bundled implementation may clarify which backend you are using:
[]
= { = "*", = false, = ["surf"]}
= { = "2.3.2", = false }
= { = "6.5.3", = false, = ["h1_client", "rustls"] }
use SurfClient;
For more details, refer to the surf documentation.