You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's based off the micropb basic example. MTest2 passes the assertion (and appears to actually de/serialize correctly), while MTest1 fails the assertion (and in fact serializes to 0 bytes). Assertion fail:
thread 'main' panicked at src/main.rs:35:3:
assertion `left == right` failed
left: MTest1 { address: Address { lsb_six_bytes: 6618611909121 }, _has: _Hazzer([0]) }
right: MTest1 { address: Address { lsb_six_bytes: 0 }, _has: _Hazzer([0]) }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The text was updated successfully, but these errors were encountered:
Ok, I think I figured it out. In the readme you mention "Note that a field will be considered empty (and ignored by the encoder) if its bit in the hazzer is not set, even if the field itself has been written." This appears to be the case for nested messages; it works if I do either
The reason is because a plain uint64 is not considered an optional field, but a nested message such as Address is always optional, so the hazzer bit is required to track presence. Easiest way to set it is via obj._has.set_address().
I am considering changing this API in the future, since it's becoming a common footgun.
Consider the following proto file.
MTest2
works, andMTest1
does not. Specifically, encoding MTest1 doesn't includeaddress
. See example project:https://github.com/Erhannis/mpb_bug_example
It's based off the micropb basic example.
MTest2
passes the assertion (and appears to actually de/serialize correctly), whileMTest1
fails the assertion (and in fact serializes to 0 bytes). Assertion fail:The text was updated successfully, but these errors were encountered: