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-default-tls(default)reqwestisahcsurf
Usage examples are provided below.
reqwest
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. By default, transport layer security (TLS) with reqwest's default-tls feature is used.
[]
= "*"
use ReqwestClient;
If you want to use the rustls TLS backend, or use reqwest::Client with your own configuration, you can directly specify with the ReqwestClientBuilder:
[]
= { = "*", = false, = ["reqwest"] }
= { = "0.11.24", = 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.
WASM support
When the target_arch is wasm32, only reqwest::* will be enabled, and its
client implementation automatically switches to the WASM one .