From ede76e8c617bc9c38dbcaaf66a15c36167ef2254 Mon Sep 17 00:00:00 2001 From: Spring_MT Date: Sat, 26 Jul 2025 23:52:04 +0900 Subject: [PATCH] Add documentation for decompress_with_pos method - Add section explaining decompress_with_pos method in StreamingDecompress - Include usage example showing how to track consumed input bytes - Clarify use cases for position tracking in streaming decompression --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 59c60e9..658384e 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,20 @@ result << stream.decompress(cstr[10..-1]) DDict can also be specified to `dict:`. +#### Streaming Decompression with Position Tracking + +If you need to know how much of the input data was consumed during decompression, you can use the `decompress_with_pos` method: + +```ruby +cstr = "" # Compressed data +stream = Zstd::StreamingDecompress.new +result, consumed_bytes = stream.decompress_with_pos(cstr[0, 10]) +# result contains the decompressed data +# consumed_bytes contains the number of bytes from input that were processed +``` + +This is particularly useful when processing streaming data where you need to track the exact position in the input stream. + ### Skippable frame ```ruby