binrw
binrw copied to clipboard
Add `br(map_reader)` attribute
Motivation
Being able to utilize reader adapters easily would greatly improve multiple areas of binrw that could use a bit of improvement:
- Parsing from decompressed or encrypted content
- Ensuring a field doesn't read past a specific size
- Easier "parse until end of section" ability (something akin to the
.take(...)
io::Read adapter[^1])
[^1]: io::Take
does not support seeking so this functionality would also be needed (likely 2 variants, one for "seeks relative to current position" and one for "seeks relative to start of inner reader")
Syntax
#[br(map_reader = $map_fn:expr)]
I feel like this, or something very similar, would also be the correct solution for issues like #102.
Also, regarding footnote 1, I already have a TakeSeek type that can be used.