Replies: 1 comment 10 replies
-
Something like this, where the bit read is used for an enum: use deku::prelude::*;
#[derive(DekuRead, DekuWrite, Debug)]
pub struct A {
#[deku(bits = 1)]
bit: u8,
#[deku(ctx = "*bit")]
var: Var,
}
#[derive(DekuRead, DekuWrite, Debug)]
#[deku(id = "bit", ctx = "bit: u8")]
pub enum Var {
#[deku(id = 0)]
False(u8),
#[deku(id = 1)]
True(u32),
} |
Beta Was this translation helpful? Give feedback.
10 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there a way to specify that the number of bytes (or bits) of an integer is an expression?
So for example, to specify that the length depends on a preceding bit somewhere in the structure? if it is 1 then the integer is u32 otherwise it is u8?
Beta Was this translation helpful? Give feedback.
All reactions