Skip to content

The whole design and the documentation around endianess and how they interact with ctx is confusing as heck #622

@hechang27-sprt

Description

@hechang27-sprt
#[derive(Debug, PartialEq, Eq, DekuRead, DekuWrite)]
#[deku(endian = "big")]
pub struct IpHeader {
    #[deku(bits = 4)]
    version: u8,
    #[deku(ctx = "*version")]
    header: IpSubHeader,
}

#[derive(Debug, PartialEq, Eq, DekuRead, DekuWrite)]
#[deku(endian = "big", ctx = "version: u8", id = "version")]
pub enum IpSubHeader {
    #[deku(id = 4)]
    Ipv4(Ipv4Header),
    #[deku(id = 6)]
    Ipv6(Ipv6Header),
}

// type definition for Ipv4Header and Ipv6Header

Every thing is specified with endian = "big", yet I'm still getting these errors:

mismatched types
expected type `u8`
  found tuple `(Endian, u8)`
mismatched types
expected `()`, found `Endian`

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions