Skip to content

Commit aab60b0

Browse files
marciorasfmarcio.andrade
and
marcio.andrade
authored
[Rust] get proper version for composite types. (#1058)
Co-authored-by: marcio.andrade <[email protected]>
1 parent 9383d24 commit aab60b0

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ tasks.register('generateRustTestCodecs', JavaExec) {
672672
'sbe-tool/src/test/resources/issue984.xml',
673673
'sbe-tool/src/test/resources/issue987.xml',
674674
'sbe-tool/src/test/resources/issue1028.xml',
675+
'sbe-tool/src/test/resources/issue1057.xml',
675676
'sbe-tool/src/test/resources/fixed-sized-primitive-array-types.xml',
676677
'sbe-tool/src/test/resources/example-bigendian-test-schema.xml',
677678
'sbe-tool/src/test/resources/nested-composite-name.xml',

rust/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ issue_972 = { path = "../generated/rust/issue972" }
1717
issue_984 = { path = "../generated/rust/issue984" }
1818
issue_987 = { path = "../generated/rust/issue987" }
1919
issue_1028 = { path = "../generated/rust/issue1028" }
20+
issue_1057 = { path = "../generated/rust/issue1057" }
2021
baseline_bigendian = { path = "../generated/rust/baseline-bigendian" }
2122
nested_composite_name = { path = "../generated/rust/nested-composite-name" }
2223
fixed_sized_primitive_array = { path = "../generated/rust/fixed_sized_primitive_array" }

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1686,7 +1686,9 @@ private static void generateCompositeDecoder(
16861686
indent(out, 2, "offset: usize,\n");
16871687
indent(out, 1, "}\n\n");
16881688

1689-
final int version = tokens.get(1).version(); // skip BEGIN_COMPOSITE
1689+
// The version of the composite type is the greatest version of its fields.
1690+
final int version = tokens.stream().mapToInt(Token::version).max().orElse(0);
1691+
16901692
appendImplReaderForComposite(schemaVersionType, version, out, 1, decoderName);
16911693

16921694
// impl<'a, P> start
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<sbe:messageSchema
2+
xmlns:ns2="http://www.fixprotocol.org/ns/simple/1.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:sbe="http://fixprotocol.io/2016/sbe"
5+
package="issue1057"
6+
id="1057"
7+
version="4"
8+
semanticVersion="8.2.3"
9+
description="B3 Binary Entrypoint FIXP messages"
10+
byteOrder="littleEndian"
11+
xsi:schemaLocation="http://fixprotocol.io/2016/sbe sbe.xsd">
12+
<types>
13+
<set name="EventIndicator" encodingType="uint8" description="Set of indicators for a given event. First use case: indicates possible retransmission of message during recovery process." sinceVersion="4">
14+
<choice name="PossResend" description="1=Message is sent during recovery process, 0=Normal message.">0</choice>
15+
</set>
16+
<type name="SessionID" primitiveType="uint32" semanticType="Int" description="Client connection identification on the gateway assigned by B3."/>
17+
<composite name="messageHeader" description="Message identifiers and length of message root.">
18+
<type name="blockLength" primitiveType="uint16" description="Length of the root of the FIX message contained before repeating groups or variable/conditions fields."/>
19+
<type name="templateId" primitiveType="uint16" description="Template ID used to encode the message."/>
20+
<type name="schemaId" primitiveType="uint16" description="ID of the system publishing the message."/>
21+
<type name="version" primitiveType="uint16" description="Schema version."/>
22+
</composite>
23+
<composite name="OutboundBusinessHeader" description="Header used for outbound business messages.">
24+
<ref name="sessionID" type="SessionID"/>
25+
<ref name="eventIndicator" type="EventIndicator" sinceVersion="4"/>
26+
</composite>
27+
</types>
28+
29+
<sbe:message name="ExecutionReport_New" id="200" description="Execution Report - New message is sent in response to a NewOrderSingle or SimpleNewOrder messages, or also from a restated iceberg order.">
30+
<field name="businessHeader" type="OutboundBusinessHeader" id="35524" description="Common header to all outbound business messages."/>
31+
</sbe:message>
32+
</sbe:messageSchema>

0 commit comments

Comments
 (0)