private static void generatePrimitiveArrayDecoder(
        final StringBuilder sb,
        final int level,
        final Token fieldToken,
        final Token typeToken,
        final String name,
        final Encoding encoding) throws IOException
    {
        final PrimitiveType primitiveType = encoding.primitiveType();
        final String rustPrimitiveType = rustTypeName(primitiveType);

        final int arrayLength = typeToken.arrayLength();
        assert arrayLength > 1;

        indent(sb, level, "#[inline]\n");
        indent(sb, level, "pub fn %s(&self) -> [%s; %d] {\n",
            formatFunctionName(name),
            rustPrimitiveType,
            arrayLength);

        if (fieldToken.version() > 0)
        {
            indent(sb, level + 1, "if self.acting_version() < %d {\n", fieldToken.version());
            indent(sb, level + 2, "return [%s; %d];\n", rustNullLiteral(encoding), arrayLength);
            indent(sb, level + 1, "}\n\n");
        }

        indent(sb, level + 1, "let buf = self.get_buf();\n");
        if (rustPrimitiveType.equals("u8"))
        {
            indent(sb, level + 1, "ReadBuf::get_bytes_at(buf.data, self.%s)\n",
                getBufOffset(typeToken));
            indent(sb, level, "}\n\n");
            return;
        }

        indent(sb, level + 1, "[\n");
        for (int i = 0; i < arrayLength; i++)
        {
            if (i == 0)
            {
                indent(sb, level + 2, "buf.get_%s_at(self.%s),\n",
                    rustPrimitiveType,
                    getBufOffset(typeToken));
            }
            else
            {
                indent(sb, level + 2, "buf.get_%s_at(self.%s + %d),\n",
                    rustPrimitiveType,
                    getBufOffset(typeToken),
                    i * primitiveType.size());
            }
        }
        indent(sb, level + 1, "]\n");
        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