zip-rs / zip-old

Zip implementation in Rust
MIT License
731 stars 204 forks source link

parameterize ZipFile by stream type and remove the lifetime so it can be Send + 'static #408

Closed cosmicexplorer closed 5 months ago

cosmicexplorer commented 1 year ago

It's currently difficult to use this crate in async Rust code. One reason for that is the requirement that all captured variables in closures for most async executors must be Send + 'static, neither of which is true for ZipFile<'a> right now, requiring unsafe workarounds for the lifetime rules (e.g. casting a pointer to a usize, as in https://github.com/cosmicexplorer/symbolic-fs/blob/827a71e72cd7e3f5b7fd3fe2a0f3ad836508eff6/handles/src/lib.rs#L479).

This change does two things:

  1. Parameterize ZipFile<S> by the type of the inner readable stream S, and remove the lifetime requirement.
  2. Roll our own Limiter<S> to perform the role of io::Take<&mut dyn R>.

This is unfortunately a breaking change because ZipFile is a public API.

Pr0methean commented 5 months ago

This repo is no longer maintained. Could you please rebase this PR against https://github.com/zip-rs/zip2 and submit it there?