New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async support #204
Async support #204
Conversation
Current state:
Edit: Soft update, currently studying for exams so it will be a couple of weeks before I can finish this. |
47e5a4b
to
f781d7b
Compare
3d54901
to
56dfcf9
Compare
Would it be possible to push the MSRV back at all? What features are we using from 1.45? |
Yes it would be, the only thing that requires 1.45 is the tests because they depend on Tokio. 1.35 is the async/await MSRV iirc which is a hard minimum for syntactic reasons. This does use other parts of Tokio in the main crate but currently those parts compile fine under 1.35. This is, of course, subject to change without a minor version bump. The only thing used from Tokio in the main crate as far as I remember is the read_u32 and similar methods which I could probably try to get implemented in futures. Perhaps the simplest solution is to have a MSRV for non-async builds (it should be unchanged?) and one for async (1.45). |
I think documenting that the file must be read til the end before the reader can be reused is a reasonable comprimise until we have async destructors. Once they arrive we can reinstate drop, but for the moment it's not worth passing through an executor.
f4f1579
to
e0b62f4
Compare
I've added untested support for zip writing, I'll convert the tests soon. |
If you want to merge reading before writing is done feel free to review f5fda10, it just failed CI because of some dead code which will be used in the write implementation. |
@zacps if I do something like let file = tokio::fs::File::open(&zip_path).await?;
let mut archive = zip::AsyncZipArchive::new(file)?; I get this error:
do I need to do something like implement |
The external API is based on the There are adapters around, but the implementations are quite simple. This is an annoying wart of the ecosystem at the moment. |
This would be great! any chance of it being merged anytime soon ? |
I'm quite busy at the moment so I'm not sure if I'll have the time to rebase this right now. If someone else wants to give it a shot go for it. As far as review, @Plecra if this gets rebased will you have time to review it? |
[package]
name = "test"
version = "0.1.0"
edition = "2018"
[dependencies]
async-compat = "0.2"
tokio = { version = "1.6", features = ["macros", "rt", "fs", "rt-multi-thread"] }
zip = { git = "https://github.com/zacps/zip-rs", branch = "async-attempt2", features = ["async"]}
use async_compat::CompatExt;
#[tokio::main]
async fn main() {
tokio::spawn(foo()).await;
}
async fn foo() {
let file = tokio::fs::File::open("foo").await.unwrap();
let file = file.compat();
let mut archive = zip::read::AsyncZipArchive::new(file).await.unwrap();
let zip_file = archive.by_index(0).await.unwrap();
} Resulting error from
|
@nick-e Thanks for pointing that out. Unfortunately I'm a bit short of time at the moment, so it's unlikely I'll have the time to fix that and resolve merge conflicts until my semester ends at the earliest (mid November). If someone else has the bandwidth to push this through then please go ahead. |
@zacps Did you find any time to work on this PR? :) |
@zhengxiwan could you please use English here? :) It will be a lot easier to understand you :) |
@zamazan4ik That was apparently an automated out of office response. |
Thanks for the clarification :) |
Unfortunately it's unlikely I'll have time to work on this in the foreseeable future. Please feel free to work on this if you have time. |
Thanks for the time you did spend on this 😊 Sorry we weren't able to match it with the rest of the crate for now. |
This is now in a good state.
To be clear, this only implements.async
zip reading, writing is not added in this PRFixes #124