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

        indent(sb, level, "#[inline]\n");
        indent(sb, level, "pub fn %s_at(&mut self, index: usize, value: %s) {\n",
            formatFunctionName(name), rustPrimitiveType);
        indent(sb, level + 1, "let offset = self.%s;\n", getBufOffset(typeToken));
        indent(sb, level + 1, "let buf = self.get_buf_mut();\n");

        if (primitiveType.size() == 1)
        {
            indent(sb, level + 1, "buf.put_%s_at(offset + index, value);\n", rustPrimitiveType);
        }
        else
        {
            indent(sb, level + 1, "buf.put_%s_at(offset + index * %d, value);\n",
                rustPrimitiveType, primitiveType.size());
        }
        indent(sb, level, "}\n\n");

        indent(sb, level, "/// primitive array field '%s'\n", name);
        generateRustDoc(sb, level, typeToken, encoding);
        indent(sb, level, "#[inline]\n");
        indent(sb, level, "pub fn %s(&mut self, value: &[%s]) {\n",
            formatFunctionName(name), rustPrimitiveType);

        // NB: must create variable 'offset' before calling mutable self.get_buf_mut()
        indent(sb, level + 1, "debug_assert_eq!(%d, value.len());\n", arrayLength);
        indent(sb, level + 1, "let offset = self.%s;\n", getBufOffset(typeToken));
        indent(sb, level + 1, "let buf = self.get_buf_mut();\n");

        if (rustPrimitiveType.equals("u8"))
        {
            indent(sb, level + 1, "buf.put_slice_at(offset, value);\n");
            indent(sb, level, "}\n\n");
        }
        else
        {
            for (int i = 0; i < arrayLength; i++)
            {
                if (i == 0)
                {
                    indent(sb, level + 1, "buf.put_%s_at(offset, value[%d]);\n", rustPrimitiveType, i);
                }
                else
                {
                    indent(sb, level + 1, "buf.put_%s_at(offset + %d, value[%d]);\n",
                        rustPrimitiveType,
                        i * primitiveType.size(),
                        i);
                }
            }

            indent(sb, level, "}\n\n");
        }

        generatePrimitiveArrayFromIterEncoder(sb, level, typeToken, name);
        generatePrimitiveArrayZeroPaddedEncoder(sb, level, typeToken, name);
    }
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