private static void generatePrimitiveEncoder(
        final StringBuilder sb,
        final int level,
        final Token typeToken,
        final String name) throws IOException
    {
        final int arrayLength = typeToken.arrayLength();
        if (arrayLength > 1)
        {
            generatePrimitiveArrayEncoder(sb, level, typeToken, name);
            return;
        }

        final Encoding encoding = typeToken.encoding();
        if (encoding.presence() == Encoding.Presence.CONSTANT)
        {
            indent(sb, level, "// skipping CONSTANT %s\n\n", name);
            return;
        }

        final PrimitiveType primitiveType = encoding.primitiveType();
        final String rustPrimitiveType = rustTypeName(primitiveType);

        indent(sb, level, "/// primitive 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, "let offset = self.%s;\n", getBufOffset(typeToken));
        indent(sb, level + 1, "self.get_buf_mut().put_%s_at(offset, value);\n", rustPrimitiveType);
        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