Skip to content

feat(io): add reader implementation for BufRead#196

Open
kskalski wants to merge 1 commit intoanza-xyz:masterfrom
kskalski:ks/buf_read
Open

feat(io): add reader implementation for BufRead#196
kskalski wants to merge 1 commit intoanza-xyz:masterfrom
kskalski:ks/buf_read

Conversation

@kskalski
Copy link
Contributor

@kskalski kskalski commented Feb 18, 2026

Introduces BufReadAdapter<R> in wincode::io::std_read module, a low-overhead wrapper over any std::io::BufRead source (e.g. BufReader<R>) implementing wincode::io::Reader.

Mix of consuming and scoped borrowing operations supported by checking consume state on each operation and using one of:

  • Fast path — when the reader’s internal buffer already holds enough bytes, peek_array and take_scoped return a subslice directly with no allocation, copy_into_slice uses read directly into the dst buffer
  • Aux-buffer fallback — when a contiguous slice larger than one currently available from internal reader's fill_buf is requested, bytes are assembled into an aux_buf: Vec<u8>. Subsequent operations can re-serve or extend from this buffer, but switch back to using internal reader once the bytes in aux_buf are consumed.

@kskalski kskalski force-pushed the ks/buf_read branch 9 times, most recently from 75e8eec to b4dd766 Compare March 18, 2026 09:06
@kskalski kskalski marked this pull request as ready for review March 18, 2026 10:33
@kskalski kskalski requested review from cpubot March 18, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant