typesense / typesense-rust

Rust client for Typesense | Work In Progress & Help Wanted
Apache License 2.0
32 stars 12 forks source link

HttpLowLevel not Send #23

Closed m0ppers closed 2 years ago

m0ppers commented 2 years ago

This makes it non-trivial to use it in https://github.com/tokio-rs/axum/ as that would require Futures to be Send. It is explicitly marked as ?Send here: https://github.com/typesense/typesense-rust/blob/97ce33dad948335a6ebd238a332ad29b002ab93f/typesense/src/transport/http_low_level.rs#L16

When I just remove the ?Send stuff it works for me so I am wondering if it can be safely removed? Is this because of wasm ?

morenol commented 2 years ago

Good catch, could you create a PR with that?

Yes, it is the because of wasm, but we could have two version of that trait. Using the

#[cfg(not(target_arch = "wasm32"))]
 #[async_trait()] 
pub trait HttpLowLevel<M = http::Method, H = http::HeaderMap> {

#[cfg(target_arch = "wasm32")]
 #[async_trait(?Send)] 
pub trait HttpLowLevel<M = http::Method, H = http::HeaderMap> {