Skip to content

Support Selector prefix for enum #67

@crab2313

Description

@crab2313

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions