Currently, std.compress.flate.Compress.writer.flush writes out the footer and transitions the writer to .failing, basically prohibiting its future use. This ultimately forces a pattern where one cannot use something like a fixed writer as the bit writer for a compression stream, unless you can guarantee that the whole compressed stream will fit in the buffer. Rather, if you need to chunk the output in some way outside of the normal bit stream (e.g., PNG IDAT), you are forced into the pattern of implementing your own writer (mind you, this was a fairly trivial task for me).
In https://github.com/ziglang/zig/pull/25301 it looks like this was noted with regards to the comments on general flush semantics so I'd imagine that this is pending, but I just wanted to make a note as I did run into it porting my graphics library's PNG export from a buffer-based setup (backed by a FixedBufferStream) to the aforementioned locally-implemented writer.
Just one other note for the prior art: the 0.14.1 flush has some comments to how the bit stream is tied off in a flush operation, which might be useful to adopt, but I don't claim enough expertise to say one way or another, and I'm sure folks are probably aware of it already too. 🙂
Currently, `std.compress.flate.Compress.writer.flush` writes out the footer and transitions the writer to `.failing`, basically prohibiting its future use. This ultimately forces a pattern where one cannot use something like a fixed writer as the bit writer for a compression stream, unless you can guarantee that the whole compressed stream will fit in the buffer. Rather, if you need to chunk the output in some way outside of the normal bit stream (e.g., PNG IDAT), you are forced into the pattern of implementing your own writer (mind you, this was a fairly trivial task for me).
In https://github.com/ziglang/zig/pull/25301 it looks like this was noted with regards to the comments on general `flush` semantics so I'd imagine that this is pending, but I just wanted to make a note as I did run into it porting my graphics library's PNG export from a buffer-based setup (backed by a `FixedBufferStream`) to the aforementioned locally-implemented writer.
Just one other note for the prior art: [the 0.14.1 `flush`](https://codeberg.org/ziglang/zig/src/commit/d03a147ea0a590ca711b3db07106effc559b0fc6/lib/std/compress/flate/deflate.zig#L323-L337) has some comments to how the bit stream is tied off in a flush operation, which might be useful to adopt, but I don't claim enough expertise to say one way or another, and I'm sure folks are probably aware of it already too. 🙂