Repository navigation
Conversation
The C API has had inflateCopy from the start; the Rust `Inflate` type had no way to copy a decompressor. `try_clone` returns a copy at the current point, from which both continue independently. It is what random access into a deflate stream is built on: copies saved while the stream is read through, decoding resumed later from the nearest one below the wanted position. `inflate::copy` refused a stream that had not run yet (null buffer pointers). The pointers are copied, never read, so that check is gone; the one inconsistent state, input claimed without a buffer, is still rejected.
zone117x
force-pushed
the
inflate-try-clone
branch
from
September 6, 2026 02:15
62881b2 to
4a21265
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The C API has had
inflateCopyfrom the start; the RustInflatetype had no way to copy a decompressor. This addsInflate::try_clone, which returns a copy at the current point, from which both continue independently. It is what random access into a deflate stream is built on (zlib'szranexample, or a state copy every few MiB): copies saved while the stream is read through, decoding resumed later from the nearest one below the wanted position. We use it for a checkpoint index over gzip in an archive manager, so that a member of a.tar.gzopens in milliseconds rather than after a full decode; until now that meant callinginflateCopythroughlibz-rs-sysfrom Rust, since theinflatemodule sits behind__internal-api.inflate::copyrefused a stream that had not run yet (nullnext_out). The buffer pointers are copied, never read, so that check is gone; the one inconsistent state, input claimed without a buffer, is still rejected. Two unit tests cover a copy mid-stream and one before the first call.try_clonerather thanClone, since the state allocation can fail and the crate reportsMemErroreverywhere else.