Open r4v3n6101 opened 2 years ago
I think you would use something like then
https://docs.rs/combine/4.6.3/combine/trait.Parser.html#method.then .
header()
.then(|header| {
parse(|input| {
// Do a separate parse at the offset(s)
let (output, _input) = my_parser().parse_state(&input[header.offset..])?;
// Then return the original input to continue parsing there (or return the input where you want to continue parsing)
Ok((output, input))
})
})
That's exact functionality that I need. Thanks!
Let me ask a question, what do you think about new in-crate parser called offset
. It's kind of look_ahead + skip: we go to our offset as the current base index, but when we're out of this parser it uses previous index. I can provide test implementation of my idea, just let me know what you think about it.
Sure, that seems generally useful.
Hello. First of all, my thanks for this crate. So, I'm working on binary data parser, but I have some problems about offsets. Structure looks like this:
How can I solve the problem of offset access using
combine
crate? Header and data by offsets should be stored in custom struct. Thanks in advance!