There currently generate following const items in message codec files:
pub const SBE_BLOCK_LENGTH: u16 = 26;
pub const SBE_TEMPLATE_ID: u16 = 400;
pub const SBE_SCHEMA_ID: u16 = 10;
pub const SBE_SCHEMA_VERSION: u16 = 1;
pub const SBE_SEMANTIC_VERSION: &str = "1.0.0";
Actually SBE_SCHEMA_ID and SBE_SCHEMA_VERSION and SBE_SEMANTIC_VERSION were crate level info, and might also be placed in lib.rs.
pub const SBE_SCHEMA_ID: u16 = 10;
pub const SBE_SCHEMA_VERSION: u16 = 1;
pub const SBE_SEMANTIC_VERSION: &str = "1.0.0";
A typical usecase for this is that when using multi sbe generated crates in a single bin crate to decode bytes. Each sbe crate may contain multi message types. So a general pattern to decode bytes was:
let frame_container = ...;
let msg_schema = frame_container.message_schema();
match msg_schema {
crate_a::SBE_SCHEMA_ID => {
// use crate_a specific ReadBuf and HeaderDecoder and ...
}
crate_b::SBE_SCHEMA_ID => {
// use crate_b specific ReadBuf and HeaderDecoder and ...
}
_ => {}
}