winnow-rs / winnow

Making parsing a breeze
https://docs.rs/winnow
Other
573 stars 46 forks source link

Port over nom-bitvec #564

Open kszlim opened 4 months ago

kszlim commented 4 months ago

Please complete the following tasks

winnow version

0.6.13

Describe your use case

The bits module in winnow doesn't allow for different traversal orders over the bits and other bit level niceties.

Would be really ergonomic, I think including it directly into winnow (as opposed to nom's approach of having it as a plugin) would be very nice for a batteries included experience (and is less likely to bitrot).

Describe the solution you'd like

Supporting something like this (directly lifted from nom-bitvec):

fn parser(bits: &BitSlice<Msb0, u8>) -> IResult<&BitSlice<Msb0, u8>, &BitSlice<Msb0, u8>> {
    tag(bits![1, 0, 1, 0])(bits)
}

would be very ergonomic.

Alternatives, if applicable

No response

Additional Context

No response

epage commented 4 months ago

Wow, talk about rot

yet all three versions are for nom v7.

The downside to including this directly in is it adds bitvec to our publish dependencies. While I've been more liberal with breaking releases than bitvec, I am a bit hesitant to do so. This is independent of making it a feature. Most likely, at least initially, this would be a crate in the workspace. That at least addresses the problem of bitrot as everything would be updated together.

In general, I've wondered if winnow should be split up more to better focus on text vs binary though likely that wouldn't happen until open-namespaces feature is available.

kszlim commented 4 months ago

Yeah, I think it makes sense to make it a crate in the workspace!