sharksforarms / deku

Declarative binary reading and writing: bit-level, symmetric, serialization/deserialization

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Assert for tuple enum

libklein opened this issue · comments

I am wondering whether it is possible to define assertions over (anonymous) tuple structs, as in the following example:

#[derive(DekuRead, DekuWrite)]
#[deku(type = "u8", bits = "1")]
pub enum RegisterOrValue {
    #[deku(id = "0b0")]
    Field(#[deku(assert = "*??? < 32")] u8),
}

Is there some deku internal name that could be used to reference the parsed u8?

Try the following: #[deku(assert = "*field_0 < 32")] u8