Open Bauxitedev opened 1 year ago
It does not support async internally and probably won't in the near future.
One goal of this library is to have zero dependencies, and from a quick glance all the async io examples I see use other crates. I'm not saying it'll never happen, but it looks like it'll increase the complexity of the library quite a bit.
As for your file upload example I don't have any specific help to give you, but I do use this crate in an async context via Serenity with no issues. I don't do anything special, I just call it from inside an async function and the library handles execution.
I see. For anyone else looking for async support, this is the workaround I managed to come up with. file
is a tokio::fs::File
.
let std_file = file.try_clone().await?.into_std().await;
let imgsize = spawn_blocking(|| {
imagesize::reader_size(std::io::BufReader::new(std_file))
})
.await
.expect("Panic occured while trying to infer image size")?;
Does this crate support async? If not, how would I go about using this in an async context? (e.g. for a file upload in an async web server)