private static void generateCompositeDecoder(
        final StringBuilder sb,
        final int level,
        final Token fieldToken,
        final Token typeToken,
        final String name) throws IOException
    {
        final String decoderName = toLowerSnakeCase(decoderName(name));
        final String referencedName = typeToken.referencedName();
        final String decoderTypeName = format("%s::%s",
            codecModName(referencedName == null ? typeToken.name() : referencedName),
            decoderName(formatStructName(typeToken.applicableTypeName())));
        indent(sb, level, "/// COMPOSITE DECODER\n");
        indent(sb, level, "#[inline]\n");
        if (fieldToken.version() > 0)
        {
            indent(sb, level, "pub fn %s(self) -> Either<Self, %2$s<Self>> {\n",
                decoderName,
                decoderTypeName);

            indent(sb, level + 1, "if self.acting_version() < %d {\n", fieldToken.version());
            indent(sb, level + 2, "return Either::Left(self);\n");
            indent(sb, level + 1, "}\n\n");

            indent(sb, level + 1, "let offset = self.%s;\n", getBufOffset(fieldToken));
            indent(sb, level + 1, "Either::Right(%s::default().wrap(self, offset))\n",
                decoderTypeName);
        }
        else
        {
            indent(sb, level, "pub fn %s(self) -> %s<Self> {\n",
                decoderName,
                decoderTypeName);

            indent(sb, level + 1, "let offset = self.%s;\n", getBufOffset(fieldToken));
            indent(sb, level + 1, "%s::default().wrap(self, offset)\n", decoderTypeName);
        }
        indent(sb, level, "}\n\n");
    }
Create a new Rust language {@link CodeGenerator}.

@param ir            for the messages and types.
@param crateVersion  for the generated crate.
@param outputManager for generating the codecs to.
sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/rust/RustGenerator.java