binrw
binrw copied to clipboard
Writing enums: pre_assert?
I have code like this:
#[derive(BinRead, BinWrite, Debug)]
#[brw(import(message_type: u8))]
enum MessageData {
#[br(pre_assert(message_type == 0x0u8))] Nil {
},
...
}
bw
/ brw
don't allow pre_assert
so they can't serialize this. Is there a way to reverse parsing an enum like this? Is it feasible to implement pre_assert
for brw
?... I don't think using assert
is correct.