Skip to content

Commit 3d35c50

Browse files
committed
[Rust] use pub use instead of duplicated defines for message schema items in message codec
1 parent 5d33b22 commit 3d35c50

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/rust/RustGenerator.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,15 @@ public void generate() throws IOException
159159
indent(out, 0, "use crate::*;\n\n");
160160
indent(out, 0, "pub use decoder::%sDecoder;\n", formatStructName(msgToken.name()));
161161
indent(out, 0, "pub use encoder::%sEncoder;\n\n", formatStructName(msgToken.name()));
162+
163+
indent(out, 0, "pub use crate::SBE_SCHEMA_ID;\n");
164+
indent(out, 0, "pub use crate::SBE_SCHEMA_VERSION;\n");
165+
indent(out, 0, "pub use crate::SBE_SEMANTIC_VERSION;\n\n");
166+
162167
final String blockLengthType = blockLengthType();
163168
final String templateIdType = rustTypeName(ir.headerStructure().templateIdType());
164-
final String schemaIdType = rustTypeName(ir.headerStructure().schemaIdType());
165-
final String schemaVersionType = schemaVersionType();
166-
final String semanticVersion = ir.semanticVersion() == null ? "" : ir.semanticVersion();
167169
indent(out, 0, "pub const SBE_BLOCK_LENGTH: %s = %d;\n", blockLengthType, msgToken.encodedLength());
168-
indent(out, 0, "pub const SBE_TEMPLATE_ID: %s = %d;\n", templateIdType, msgToken.id());
169-
indent(out, 0, "pub const SBE_SCHEMA_ID: %s = %d;\n", schemaIdType, ir.id());
170-
indent(out, 0, "pub const SBE_SCHEMA_VERSION: %s = %d;\n", schemaVersionType, ir.version());
171-
indent(out, 0, "pub const SBE_SEMANTIC_VERSION: &str = \"%s\";\n\n", semanticVersion);
170+
indent(out, 0, "pub const SBE_TEMPLATE_ID: %s = %d;\n\n", templateIdType, msgToken.id());
172171

173172
MessageCoderDef.generateEncoder(ir, out, msgToken, fields, groups, varData);
174173
MessageCoderDef.generateDecoder(ir, out, msgToken, fields, groups, varData);

0 commit comments

Comments
 (0)