Skip to content

Commit d03cda8

Browse files
committed
add feature for clients that do not implement send
1 parent 043a553 commit d03cda8

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ wasm-bindgen-futures = "0.4"
4040
[features]
4141
default = ["reqwest"]
4242
reqwest = ["dep:reqwest", "pin-project-lite", "bytes"]
43+
futures-unsend = []
4344

4445
[dev-dependencies]
4546
futures-await-test = "0.3"

examples/cli-app-with-awc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ publish = false
77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

99
[dependencies]
10-
meilisearch-sdk = { path = "../..", default-features = false }
10+
meilisearch-sdk = { path = "../..", default-features = false, features = ["futures-unsend"] }
1111
futures = "0.3"
1212
serde = { version = "1.0", features = ["derive"] }
1313
serde_json = "1.0"

src/request.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ impl<Q, B> Method<Q, B> {
6565
}
6666
}
6767

68-
#[async_trait(?Send)]
68+
#[cfg_attr(feature = "futures-unsend", async_trait(?Send))]
69+
#[cfg_attr(not(feature = "futures-unsend"), async_trait)]
6970
pub trait HttpClient: Clone + Send + Sync {
7071
async fn request<Query, Body, Output>(
7172
&self,
@@ -143,7 +144,8 @@ pub fn parse_response<Output: DeserializeOwned>(
143144
}
144145
}
145146

146-
#[async_trait(?Send)]
147+
#[cfg_attr(feature = "futures-unsend", async_trait(?Send))]
148+
#[cfg_attr(not(feature = "futures-unsend"), async_trait)]
147149
impl HttpClient for Infallible {
148150
async fn request<Query, Body, Output>(
149151
&self,

src/reqwest.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ impl ReqwestClient {
5050
}
5151
}
5252

53-
#[async_trait(?Send)]
53+
#[cfg_attr(feature = "futures-unsend", async_trait(?Send))]
54+
#[cfg_attr(not(feature = "futures-unsend"), async_trait)]
5455
impl HttpClient for ReqwestClient {
5556
async fn stream_request<
5657
Query: Serialize + Send + Sync,

0 commit comments

Comments
 (0)