From 5c9219dcbe45b57bc01e266f8898352a7c1ade67 Mon Sep 17 00:00:00 2001 From: sugyan Date: Tue, 27 Feb 2024 00:13:12 +0900 Subject: [PATCH] Fix documentations --- atrium-xrpc-client/Cargo.toml | 3 +++ atrium-xrpc-client/README.md | 29 +++++++++++++---------------- atrium-xrpc-client/src/lib.rs | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/atrium-xrpc-client/Cargo.toml b/atrium-xrpc-client/Cargo.toml index 43035215..296f22a7 100644 --- a/atrium-xrpc-client/Cargo.toml +++ b/atrium-xrpc-client/Cargo.toml @@ -26,6 +26,9 @@ reqwest = ["dep:reqwest"] reqwest-default-tls = ["reqwest/default-tls"] surf = ["dep:surf"] +[target.'cfg(target_arch = "wasm32")'.dependencies] +reqwest.workspace = true + [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] reqwest = { workspace = true, features = ["native-tls", "rustls-tls"] } surf = { workspace = true, features = ["h1-client-rustls"] } diff --git a/atrium-xrpc-client/README.md b/atrium-xrpc-client/README.md index 1b712ebe..227e7112 100644 --- a/atrium-xrpc-client/README.md +++ b/atrium-xrpc-client/README.md @@ -9,31 +9,22 @@ This library provides clients that implement the [`XrpcClient`](https://docs.rs/ ## Features -- `reqwest-native` (default) -- `reqwest-rustls` +- `reqwest-default-tls` (default) +- `reqwest` - `isahc` - `surf` Usage examples are provided below. -### `reqwest-native` and `reqwest-rustls` +### `reqwest` -If you are using [`tokio`](https://crates.io/crates/tokio) as your asynchronous runtime, you may find it convenient to utilize the [`reqwest`](https://crates.io/crates/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`. +If you are using [`tokio`](https://crates.io/crates/tokio) as your asynchronous runtime, you may find it convenient to utilize the [`reqwest`](https://crates.io/crates/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. ```toml [dependencies] atrium-xrpc-client = "*" ``` -To use the `reqwest::Client` with the `rustls` TLS backend, specify the feature as follows: - -```toml -[dependencies] -atrium-xrpc-client = { version = "*", default-features = false, features = ["reqwest-rustls"]} -``` - -In either case, you can use the `ReqwestClient`: - ```rust use atrium_xrpc_client::reqwest::ReqwestClient; @@ -43,12 +34,13 @@ fn main() -> Result<(), Box> { } ``` -You can also directly specify a `reqwest::Client` with your own configuration: + +If you want to use the `rustls` TLS backend, or use `reqwest::Client` with your own configuration, you can directly specify with the `ReqwestClientBuilder`: ```toml [dependencies] -atrium-xrpc-client = { version = "*", default-features = false } -reqwest = { version = "0.11.22", default-features = false, features = ["rustls-tls"] } +atrium-xrpc-client = { version = "*", default-features = false, features = ["reqwest"] } +reqwest = { version = "0.11.24", default-features = false, features = ["rustls-tls"] } ``` ```rust @@ -160,3 +152,8 @@ fn main() -> Result<(), Box> { ``` For more details, refer to the [`surf` documentation](https://docs.rs/surf). + +## WASM support + +When the target_arch is wasm32, only `reqwest::*` will be enabled, and its +client implementation automatically switches to the WASM one . diff --git a/atrium-xrpc-client/src/lib.rs b/atrium-xrpc-client/src/lib.rs index 800388b9..eadeb55d 100644 --- a/atrium-xrpc-client/src/lib.rs +++ b/atrium-xrpc-client/src/lib.rs @@ -5,7 +5,7 @@ #[cfg(feature = "isahc")] pub mod isahc; #[cfg_attr(docsrs, doc(cfg(feature = "reqwest")))] -#[cfg(feature = "reqwest")] +#[cfg(any(feature = "reqwest", target_arch = "wasm32"))] pub mod reqwest; #[cfg_attr(docsrs, doc(cfg(feature = "surf")))] #[cfg(feature = "surf")]