Skip to content

Commit ede76e8

Browse files
committed
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
1 parent df8713a commit ede76e8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,20 @@ result << stream.decompress(cstr[10..-1])
169169

170170
DDict can also be specified to `dict:`.
171171

172+
#### Streaming Decompression with Position Tracking
173+
174+
If you need to know how much of the input data was consumed during decompression, you can use the `decompress_with_pos` method:
175+
176+
```ruby
177+
cstr = "" # Compressed data
178+
stream = Zstd::StreamingDecompress.new
179+
result, consumed_bytes = stream.decompress_with_pos(cstr[0, 10])
180+
# result contains the decompressed data
181+
# consumed_bytes contains the number of bytes from input that were processed
182+
```
183+
184+
This is particularly useful when processing streaming data where you need to track the exact position in the input stream.
185+
172186
### Skippable frame
173187

174188
```ruby

0 commit comments

Comments
 (0)