Skip to content

Commit

Permalink
Fix documentations
Browse files Browse the repository at this point in the history
  • Loading branch information
sugyan committed Feb 26, 2024
1 parent 2d8c67e commit 5c9219d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
3 changes: 3 additions & 0 deletions atrium-xrpc-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
29 changes: 13 additions & 16 deletions atrium-xrpc-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -43,12 +34,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
}
```

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
Expand Down Expand Up @@ -160,3 +152,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
```

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 .
2 changes: 1 addition & 1 deletion atrium-xrpc-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down

0 comments on commit 5c9219d

Please sign in to comment.