temp_value being called during the read #569
Replies: 2 comments 1 reply
-
can you provide a minimal reproduction? this would help debug. |
Beta Was this translation helpful? Give feedback.
-
I'm sorry, I found my issue. I was calling To_bytes internally to calculate the CRC, but of course that is going to trigger the function, and the final to_bytes as the end will trigger it again. I'll have to think of a different way to accomplish this. Thanks for the reply, sorry for wasting your time. I do have a feature request however. Would it be possible to add a flag such that the "update" function be called automatically if present before the serialization? I feel that would make that feature much more powerful. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've got the following and am trying to use the temp_value to write out a sequence number during serialization:
#[deku(temp, temp_value="get_sequence()")]
sequence: u8,
It seems the temp_value is getting called during the de-serialization which I wouldn't expect. I would expect it to read the encoded value during the de-serialization, and use the temp_value when serializing.
Basically I have several spots in the protocol I want to read the value and use it as is during de-serialization, and provide some code during serialization. I know it could be achieved with update....but that has to be called manually with a mutable reference.
Is there any existing mechanism that would achieve this? I'm using 19.1.
Beta Was this translation helpful? Give feedback.
All reactions