@@ -29,7 +29,8 @@ use crate::error::AsyncTiffResult;
2929/// [`ObjectStore`]: object_store::ObjectStore
3030///
3131/// [`tokio::fs::File`]: https://docs.rs/tokio/latest/tokio/fs/struct.File.html
32- #[ async_trait]
32+ #[ cfg_attr( target_arch = "wasm32" , async_trait( ?Send ) ) ]
33+ #[ cfg_attr( not( target_arch = "wasm32" ) , async_trait) ]
3334pub trait AsyncFileReader : Debug + Send + Sync + ' static {
3435 /// Retrieve the bytes in `range` as part of a request for image data, not header metadata.
3536 ///
@@ -52,7 +53,8 @@ pub trait AsyncFileReader: Debug + Send + Sync + 'static {
5253}
5354
5455/// This allows Box<dyn AsyncFileReader + '_> to be used as an AsyncFileReader,
55- #[ async_trait]
56+ #[ cfg_attr( target_arch = "wasm32" , async_trait( ?Send ) ) ]
57+ #[ cfg_attr( not( target_arch = "wasm32" ) , async_trait) ]
5658impl AsyncFileReader for Box < dyn AsyncFileReader + ' _ > {
5759 async fn get_bytes ( & self , range : Range < u64 > ) -> AsyncTiffResult < Bytes > {
5860 self . as_ref ( ) . get_bytes ( range) . await
@@ -64,7 +66,8 @@ impl AsyncFileReader for Box<dyn AsyncFileReader + '_> {
6466}
6567
6668/// This allows Arc<dyn AsyncFileReader + '_> to be used as an AsyncFileReader,
67- #[ async_trait]
69+ #[ cfg_attr( target_arch = "wasm32" , async_trait( ?Send ) ) ]
70+ #[ cfg_attr( not( target_arch = "wasm32" ) , async_trait) ]
6871impl AsyncFileReader for Arc < dyn AsyncFileReader + ' _ > {
6972 async fn get_bytes ( & self , range : Range < u64 > ) -> AsyncTiffResult < Bytes > {
7073 self . as_ref ( ) . get_bytes ( range) . await
@@ -121,7 +124,8 @@ impl<T: tokio::io::AsyncRead + tokio::io::AsyncSeek + Unpin + Send + Debug> Toki
121124}
122125
123126#[ cfg( feature = "tokio" ) ]
124- #[ async_trait]
127+ #[ cfg_attr( target_arch = "wasm32" , async_trait( ?Send ) ) ]
128+ #[ cfg_attr( not( target_arch = "wasm32" ) , async_trait) ]
125129impl < T : tokio:: io:: AsyncRead + tokio:: io:: AsyncSeek + Unpin + Send + Debug + ' static >
126130 AsyncFileReader for TokioReader < T >
127131{
@@ -158,7 +162,8 @@ impl ObjectReader {
158162}
159163
160164#[ cfg( feature = "object_store" ) ]
161- #[ async_trait]
165+ #[ cfg_attr( target_arch = "wasm32" , async_trait( ?Send ) ) ]
166+ #[ cfg_attr( not( target_arch = "wasm32" ) , async_trait) ]
162167impl AsyncFileReader for ObjectReader {
163168 async fn get_bytes ( & self , range : Range < u64 > ) -> AsyncTiffResult < Bytes > {
164169 self . make_range_request ( range) . await
@@ -211,7 +216,8 @@ impl ReqwestReader {
211216}
212217
213218#[ cfg( feature = "reqwest" ) ]
214- #[ async_trait]
219+ #[ cfg_attr( target_arch = "wasm32" , async_trait( ?Send ) ) ]
220+ #[ cfg_attr( not( target_arch = "wasm32" ) , async_trait) ]
215221impl AsyncFileReader for ReqwestReader {
216222 async fn get_bytes ( & self , range : Range < u64 > ) -> AsyncTiffResult < Bytes > {
217223 self . make_range_request ( range) . await
0 commit comments