Skip to content

Commit

Permalink
[Rust] Updated code generator to resolve Issue #1028 (#1037)
Browse files Browse the repository at this point in the history
* [Rust] updated LibRsDef.generate() to add "#![allow(clippy::all)]"

* [Rust] generating 'From<ENUM> for PRIMITIVE' instead of 'Into<PRIMITIVE> for ENUM' to satisfy 'from_over_into' lint

* [Rust] removed unused method parameter

* fixed formatting

* [Rust] Updated code generator to resolve Issue #1022

* [Rust] meant issue #1028 not 1022 (renamed files accordingly)

---------

Co-authored-by: Michael Ward <mward@drw.com>
  • Loading branch information
mward and Michael Ward authored Dec 13, 2024
1 parent 3199ae7 commit 75a56d5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ tasks.register('generateRustTestCodecs', JavaExec) {
'sbe-tool/src/test/resources/issue972.xml',
'sbe-tool/src/test/resources/issue984.xml',
'sbe-tool/src/test/resources/issue987.xml',
'sbe-tool/src/test/resources/issue1028.xml',
'sbe-tool/src/test/resources/example-bigendian-test-schema.xml',
'sbe-tool/src/test/resources/nested-composite-name.xml',
]
Expand Down Expand Up @@ -866,7 +867,7 @@ tasks.register('generateGolangCodecs') {
'generateGolangFlyweightCodecTestComposite',
'generateGolangFlyweightCodecsWithXIncludes',
'generateGolangFlyweightCodecsWithXSD',
'generateIrCodecs',
'generateIrCodecs',
':sbe-all:jar'
}

Expand Down
1 change: 1 addition & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ issue_895 = { path = "../generated/rust/issue895" }
issue_972 = { path = "../generated/rust/issue972" }
issue_984 = { path = "../generated/rust/issue984" }
issue_987 = { path = "../generated/rust/issue987" }
issue_1028 = { path = "../generated/rust/issue1028" }
baseline_bigendian = { path = "../generated/rust/baseline-bigendian" }
nested_composite_name = { path = "../generated/rust/nested-composite-name" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,7 @@ private static void generateCompositeDecoder(
indent(out, 2, "offset: usize,\n");
indent(out, 1, "}\n\n");

final int version = tokens.stream().findFirst().get().version();
final int version = tokens.get(1).version(); // skip BEGIN_COMPOSITE
appendImplReaderForComposite(schemaVersionType, version, out, 1, decoderName);

// impl<'a, P> start
Expand Down
30 changes: 30 additions & 0 deletions sbe-tool/src/test/resources/issue1028.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<sbe:messageSchema
xmlns:ns2="http://www.fixprotocol.org/ns/simple/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sbe="http://fixprotocol.io/2016/sbe"
package="issue1028"
id="1028"
version="4"
semanticVersion="8.2.3"
description="B3 Binary Entrypoint FIXP messages"
byteOrder="littleEndian"
xsi:schemaLocation="http://fixprotocol.io/2016/sbe sbe.xsd">
<types>
<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">
<choice name="PossResend" description="1=Message is sent during recovery process, 0=Normal message.">0</choice>
</set>
<composite name="messageHeader" description="Message identifiers and length of message root.">
<type name="blockLength" primitiveType="uint16" description="Length of the root of the FIX message contained before repeating groups or variable/conditions fields."/>
<type name="templateId" primitiveType="uint16" description="Template ID used to encode the message."/>
<type name="schemaId" primitiveType="uint16" description="ID of the system publishing the message."/>
<type name="version" primitiveType="uint16" description="Schema version."/>
</composite>
<composite name="OutboundBusinessHeader" description="Header used for outbound business messages.">
<ref name="eventIndicator" type="EventIndicator" sinceVersion="4"/>
</composite>
</types>

<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.">
<field name="businessHeader" type="OutboundBusinessHeader" id="35524" description="Common header to all outbound business messages."/>
</sbe:message>
</sbe:messageSchema>

0 comments on commit 75a56d5

Please sign in to comment.