Skip to content

Commit b8a0247

Browse files
committed
[Rust] Add derive Copy Clone traits for decoders
1 parent 461204a commit b8a0247

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static void generateEitherEnum(final Writer writer) throws IOException
149149

150150
static void generateReadBuf(final Appendable writer, final ByteOrder byteOrder) throws IOException
151151
{
152-
indent(writer, 0, "#[derive(Debug, Default)]\n");
152+
indent(writer, 0, "#[derive(Clone, Copy, Debug, Default)]\n");
153153
indent(writer, 0, "pub struct %s<%s> {\n", READ_BUF_TYPE, BUF_LIFETIME);
154154
RustUtil.indent(writer, 1, "data: &%s [u8],\n", BUF_LIFETIME);
155155
indent(writer, 0, "}\n");

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,15 @@ void appendMessageHeaderDecoderFn(final Appendable out) throws IOException
155155

156156
void appendMessageStruct(final Appendable out, final String structName) throws IOException
157157
{
158-
indent(out, 1, "#[derive(Debug, Default)]\n");
158+
if (this.codecType == Decoder)
159+
{
160+
indent(out, 1, "#[derive(Clone, Copy, Debug, Default)]\n");
161+
}
162+
else
163+
{
164+
indent(out, 1, "#[derive(Debug, Default)]\n");
165+
}
166+
159167
indent(out, 1, "pub struct %s {\n", withLifetime(structName));
160168
indent(out, 2, "buf: %s,\n", withLifetime(this.codecType.bufType()));
161169
indent(out, 2, "initial_offset: usize,\n");

0 commit comments

Comments
 (0)