Replies: 2 comments
-
Answer part 1 (hiding the FX field): You can just make the fx-field non-public, then it is hidden. Open: automatically set the fx field |
Beta Was this translation helpful? Give feedback.
-
Possible answer part 2 (update the FX fields): You can use update to update the FX fields manually // ...
#[deku(
skip,
cond = "*part1_fx==0",
default = "Default::default()",
until = "|codefx: &Part2| codefx.fx == 0",
update = "self.part2.iter_mut().rev().enumerate().map(|(index, entry)| { entry.fx = if index!=0 {1} else {0}; entry.clone() }).rev().collect::<Vec<_>>()"
)]
part2: Vec<Part2>,
// ...
decoded.part2.push(Part2::new(2, -1, 3));
decoded.update().unwrap(); I would prefer to have an "automatic-update" called before serialization. This would - however - require the FX field to have interior mutability, since serialization is a non-mutable operation. What do you think of (a) allowing/enabling |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
Thank you for this great crate!
I explored https://docs.rs/asterix/latest/asterix/ and your crate and I am preparing some documentation on it.
In discovered the possibility to implement arrays to be read until a flag is set: https://docs.rs/asterix/latest/src/asterix/data_item.rs.html#559-562
I would like to do the same, but
temp
)temp_value
-like): only the last entry of the array gets a 0, else write a 1.Do you think we can do this in the current state of deku, or do we need some extension?
Beta Was this translation helpful? Give feedback.
All reactions