private static void generatePrimitiveArrayFromIterEncoder(
        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);

        indent(sb, level, "/// primitive array field '%s' from an Iterator\n", name);
        generateRustDoc(sb, level, typeToken, encoding);
        indent(sb, level, "#[inline]\n");
        indent(sb, level, "pub fn %s_from_iter(&mut self, iter: impl Iterator<Item = %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");
        indent(sb, level + 1, "for (i, v) in iter.enumerate() {\n");

        if (primitiveType.size() == 1)
        {
            indent(sb, level + 2, "buf.put_%s_at(offset + i, v);\n", rustPrimitiveType);
        }
        else
        {
            indent(sb, level + 2, "buf.put_%s_at(offset + i * %d, v);\n",
                rustPrimitiveType, 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