matrix-sdk: Make the http client trait WASM compatible

master
Damir Jelić 2021-01-22 18:12:46 +01:00
parent 8028c23f56
commit 9c98d0227b
1 changed files with 7 additions and 4 deletions

View File

@ -20,15 +20,17 @@ use tracing::trace;
use url::Url; use url::Url;
use matrix_sdk_common::{ use matrix_sdk_common::{
api::r0::media::create_content, async_trait, locks::RwLock, AuthScheme, FromHttpResponseError, api::r0::media::create_content, async_trait, locks::RwLock, AsyncTraitDeps, AuthScheme,
FromHttpResponseError,
}; };
use crate::{ClientConfig, Error, OutgoingRequest, Result, Session}; use crate::{ClientConfig, Error, OutgoingRequest, Result, Session};
/// Abstraction around the http layer. The allows implementors to use different /// Abstraction around the http layer. The allows implementors to use different
/// http libraries. /// http libraries.
#[async_trait] #[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
pub trait HttpSend: Sync + Send + Debug { #[cfg_attr(not(target_arch = "wasm32"), async_trait)]
pub trait HttpSend: AsyncTraitDeps {
/// The method abstracting sending request types and receiving response types. /// The method abstracting sending request types and receiving response types.
/// ///
/// This is called by the client every time it wants to send anything to a homeserver. /// This is called by the client every time it wants to send anything to a homeserver.
@ -203,7 +205,8 @@ async fn response_to_http_response(mut response: Response) -> Result<http::Respo
Ok(http_builder.body(body).unwrap()) Ok(http_builder.body(body).unwrap())
} }
#[async_trait] #[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl HttpSend for Client { impl HttpSend for Client {
async fn send_request( async fn send_request(
&self, &self,