Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Selector prefix for enum #67

Open
crab2313 opened this issue Aug 11, 2023 · 0 comments
Open

Support Selector prefix for enum #67

crab2313 opened this issue Aug 11, 2023 · 0 comments

Comments

@crab2313
Copy link

crab2313 commented Aug 11, 2023

I have a use case to parse a small packet to enum. The selector is the first byte. From the documentation I must implement something like:

#[derive(Nom)]
struct PacketParser {
    code: u8,
    #[nom(Parse = "{ |i| PacketType::parse(i, code) }")]
    packet: PacketType,
}

#[derive(Nom)]
enum PacketType {
    ....
}

It's very hard to handle the enum nested in enum case due to the selector introduced in the parse function prototype. I need a way to parse PacketType and specifying the Selector is the first byte. And PacketType::parse don't need the second parameter as the selector since the information is encoded in the first byte of packet.

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

No branches or pull requests

1 participant