simple-binary-encoding icon indicating copy to clipboard operation
simple-binary-encoding copied to clipboard

Help decoding multiple messages using rust by resolving #987

Open wbprime opened this issue 1 year ago • 0 comments

Closes #987

Say multiple messages were encoded into a continuous byte buffer. When trying to decode the first message, we might first use a MessageHeaderDecoder to get its templateId at offset=0, then decode its body using correspoded message decoder at offset+=headerLength. This is ok for current message decoder's header method with an implicit header offset=0. But when trying to decoder the second and following messages, the MessageHeaderDecoder step is ok however the body decoding step using header method would fetch bytes always from the first message body, thus is not expected.

This unexpected result occurs only when using message decoder's header method to gain ownership. Use message decoder's wrap method behaves as expected.

This pr is just a simple workaround, simple but works (see tests/issue_987_test.rs).

wbprime avatar Apr 24 '24 13:04 wbprime