Closed wbprime closed 4 weeks ago
@wbprime just to clarify, you are suggesting that the MessageHeaderDecoder
is generated with additional function:
pub fn get_limit(&self) -> usize {
self.limit + message_header_code::ENCODED_LENGTH
}
and then the generated header
functions be updated to:
pub fn header(self, mut header: MessageHeaderDecoder<ReadBuf<'a>>) -> Self {
debug_assert_eq!(SBE_TEMPLATE_ID, header.template_id());
let acting_block_length = header.block_length();
let acting_version = header.version();
let limit = header.get_limit();
self.wrap(
header.parent().unwrap(),
limit,
acting_block_length,
acting_version,
)
}
Yes, decoder wrap offset should be set to header offset + message_header_codec::ENCODED_LENGTH
when wrapping using a header I suppose.
The generated header functions should be something like:
pub fn header(self, mut header: MessageHeaderDecoder<ReadBuf<'a>>) -> Self {
debug_assert_eq!(SBE_TEMPLATE_ID, header.template_id());
let acting_block_length = header.block_length();
let acting_version = header.version();
let limit = header.get_limit();
self.wrap(
header.parent().unwrap(),
// limit,
limit + message_header_codec::ENCODED_LENGTH,
acting_block_length,
acting_version,
)
}
Yes, decoder wrap offset should be set to header offset + message_header_codec::ENCODED_LENGTH
when wrapping using a header I suppose.
The generated header functions should be something like:
pub fn header(self, mut header: MessageHeaderDecoder<ReadBuf<'a>>) -> Self {
debug_assert_eq!(SBE_TEMPLATE_ID, header.template_id());
let acting_block_length = header.block_length();
let acting_version = header.version();
let limit = header.get_limit();
self.wrap(
header.parent().unwrap(),
// limit,
limit + message_header_codec::ENCODED_LENGTH,
acting_block_length,
acting_version,
)
}
Code generator for rust would generate a
header
method for Decoder (see following)The
header
method take a header decoder and callwrap
method, passingmessage_header_codec::ENCODED_LENGTH
as offset.Considering a header decoder may be wraped with a none-zero offset
header_off
,header
method should wrap withheader_off + message_header_codec::ENCODED_LENGTH
. To support this functionality, a MessageHeaderDecoder should expose its offset via, sayget_limit()
or something else.