|
23 | 23 | import java.util.ArrayList; |
24 | 24 | import java.util.LinkedHashSet; |
25 | 25 | import java.util.stream.Stream; |
| 26 | +import uk.co.real_logic.sbe.ir.Ir; |
26 | 27 |
|
27 | 28 | import static java.nio.ByteOrder.LITTLE_ENDIAN; |
28 | 29 | import static uk.co.real_logic.sbe.generation.rust.RustGenerator.*; |
@@ -54,7 +55,7 @@ class LibRsDef |
54 | 55 | this.schemaVersionType = schemaVersionType; |
55 | 56 | } |
56 | 57 |
|
57 | | - void generate() throws IOException |
| 58 | + void generate(final Ir ir) throws IOException |
58 | 59 | { |
59 | 60 | try (Writer libRs = outputManager.createOutput("lib")) |
60 | 61 | { |
@@ -84,6 +85,8 @@ void generate() throws IOException |
84 | 85 | } |
85 | 86 | indent(libRs, 0, "\n"); |
86 | 87 |
|
| 88 | + generateSbeSchemaConsts(libRs, ir); |
| 89 | + |
87 | 90 | generateSbeErrorEnum(libRs); |
88 | 91 | generateEitherEnum(libRs); |
89 | 92 |
|
@@ -123,6 +126,17 @@ static void generateDecoderTraits(final String schemaVersionType, final Writer w |
123 | 126 | indent(writer, 0, "}\n\n"); |
124 | 127 | } |
125 | 128 |
|
| 129 | + static void generateSbeSchemaConsts(final Writer writer, final Ir ir) throws IOException |
| 130 | + { |
| 131 | + final String schemaIdType = rustTypeName(ir.headerStructure().schemaIdType()); |
| 132 | + final String schemaVersionType = rustTypeName(ir.headerStructure().schemaVersionType()); |
| 133 | + final String semanticVersion = ir.semanticVersion() == null ? "" : ir.semanticVersion(); |
| 134 | + |
| 135 | + indent(writer, 0, "pub const SBE_SCHEMA_ID: %s = %d;\n", schemaIdType, ir.id()); |
| 136 | + indent(writer, 0, "pub const SBE_SCHEMA_VERSION: %s = %d;\n", schemaVersionType, ir.version()); |
| 137 | + indent(writer, 0, "pub const SBE_SEMANTIC_VERSION: &str = \"%s\";\n\n", semanticVersion); |
| 138 | + } |
| 139 | + |
126 | 140 | static void generateSbeErrorEnum(final Writer writer) throws IOException |
127 | 141 | { |
128 | 142 | indent(writer, 0, "pub type SbeResult<T> = core::result::Result<T, SbeErr>;\n\n"); |
|
0 commit comments