@@ -18,13 +18,15 @@ pub trait Format {}
18
18
///
19
19
/// This trait defines the `deserialize_with` method, which takes a [`ResponseBody`] and returns the deserialized value.
20
20
/// The `F` type parameter allows for different implementations of the `deserialize_with` method based on the specific [`Format`] marker type used.
21
- #[ async_trait:: async_trait]
21
+ #[ cfg_attr( target_arch = "wasm32" , async_trait:: async_trait( ?Send ) ) ]
22
+ #[ cfg_attr( not( target_arch = "wasm32" ) , async_trait:: async_trait) ]
22
23
pub trait DeserializeWith < F : Format > : Sized {
23
24
async fn deserialize_with ( body : ResponseBody ) -> typespec:: Result < Self > ;
24
25
}
25
26
26
27
/// Implements [`DeserializeWith<T>`] for [`ResponseBody`], by simply returning the body stream as is.
27
- #[ async_trait:: async_trait]
28
+ #[ cfg_attr( target_arch = "wasm32" , async_trait:: async_trait( ?Send ) ) ]
29
+ #[ cfg_attr( not( target_arch = "wasm32" ) , async_trait:: async_trait) ]
28
30
impl < T : Format > DeserializeWith < T > for ResponseBody {
29
31
async fn deserialize_with ( body : ResponseBody ) -> typespec:: Result < Self > {
30
32
Ok ( body)
@@ -33,7 +35,8 @@ impl<T: Format> DeserializeWith<T> for ResponseBody {
33
35
34
36
/// Implements [`DeserializeWith<DefaultFormat>`] for an arbitrary type `D`
35
37
/// that implements [`serde::de::DeserializeOwned`] by deserializing the response body to the specified type using [`serde_json`].
36
- #[ async_trait:: async_trait]
38
+ #[ cfg_attr( target_arch = "wasm32" , async_trait:: async_trait( ?Send ) ) ]
39
+ #[ cfg_attr( not( target_arch = "wasm32" ) , async_trait:: async_trait) ]
37
40
impl < D : DeserializeOwned > DeserializeWith < DefaultFormat > for D {
38
41
async fn deserialize_with ( body : ResponseBody ) -> typespec:: Result < Self > {
39
42
body. json ( ) . await
@@ -57,7 +60,8 @@ pub struct XmlFormat;
57
60
impl Format for XmlFormat { }
58
61
59
62
#[ cfg( feature = "xml" ) ]
60
- #[ async_trait:: async_trait]
63
+ #[ cfg_attr( target_arch = "wasm32" , async_trait:: async_trait( ?Send ) ) ]
64
+ #[ cfg_attr( not( target_arch = "wasm32" ) , async_trait:: async_trait) ]
61
65
impl < D : DeserializeOwned > DeserializeWith < XmlFormat > for D {
62
66
async fn deserialize_with ( body : ResponseBody ) -> typespec:: Result < Self > {
63
67
body. xml ( ) . await
0 commit comments