-
Notifications
You must be signed in to change notification settings - Fork 2
Closed as not planned
Description
as discussed in #72, clients in wasm need some special handling using channels. The main question here is where that special handling should be done. I thought something like
async fn maybe_make_send<O, F: Future<Output = O>>(f: impl FnOnce() -> F) -> O
{
#[cfg(feature = "wasm-compat")]
{
let (tx, rx) = oneshot::channel();
spawn_local(async move {
let result = f().await;
tx.send(result); // can error, at which point we do nothing
});
rx.await.unwrap(); // error means rx dropped, could retry?
}
#[cfg(not(feature = "wasm-compat"))]
f().await
}
which could wrap something like
impl AsyncFileReader for ReqwestReader {
fn get_bytes(&self, range: Range<u64>) -> BoxFuture<'_, AsyncTiffResult<Bytes>> {
let client = self.client.clone()
let href = self.href.clone()
maybe_make_send(async move {
Ok(
client
.get(href)
.header("Range", format!("bytes={}-{}",range.start,range.end+1))
.send().await?
.bytes().await?)
}).boxed()
}
}
Otherwise, this would be its own crate and implementations from here are copied over, which is also fine
Metadata
Metadata
Assignees
Labels
No labels