Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Rust] add messageSchema level info (SBE_SCHEMA_ID/SBE_SCHEMA_VERSION and more) in lib.rs #1018

Closed
wbprime opened this issue Oct 30, 2024 · 1 comment

Comments

@wbprime
Copy link
Contributor

wbprime commented Oct 30, 2024

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 ...
}
_ => {}
}
@wbprime
Copy link
Contributor Author

wbprime commented Oct 31, 2024

Hi I've attached a pr to address this #1019. Could someone help check if it could be accepted ?

wbprime added a commit to wbprime/simple-binary-encoding that referenced this issue Oct 31, 2024
vyazelenko pushed a commit that referenced this issue Nov 13, 2024
* [Rust] generate message schema level info in lib.rs

1. add `SBE_SCHEMA_ID`
2. add `SBE_SCHEMA_VERSION`
3. add `SBE_SEMANTIC_VERSION`

* [Rust] use pub use instead of duplicated defines for message schema items in message codec

* [Rust] add tests for issue #1018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants