private static void generatePrimitiveConstantDecoder(
        final StringBuilder sb,
        final int level,
        final String name,
        final Encoding encoding) throws IOException
    {
        assert encoding.presence() == Encoding.Presence.CONSTANT;
        final PrimitiveType primitiveType = encoding.primitiveType();
        final String rustPrimitiveType = rustTypeName(primitiveType);
        final String characterEncoding = encoding.characterEncoding();

        indent(sb, level, "/// CONSTANT \n");
        final String rawConstValue = encoding.constValue().toString();
        if (characterEncoding != null)
        {
            indent(sb, level, "/// characterEncoding: '%s'\n", characterEncoding);
            indent(sb, level, "#[inline]\n");

            if (JavaUtil.isAsciiEncoding(characterEncoding))
            {
                indent(sb, level, "pub fn %s(&self) -> &'static [u8] {\n",
                    formatFunctionName(name));
                indent(sb, level + 1, "b\"%s\"\n", rawConstValue);
            }
            else if (JavaUtil.isUtf8Encoding(characterEncoding))
            {
                indent(sb, level, "pub fn %s(&self) -> &'static str {\n", formatFunctionName(name));
                indent(sb, level + 1, "\"%s\"\n", rawConstValue);
            }
            else
            {
                throw new IllegalArgumentException("Unsupported encoding: " + characterEncoding);
            }

            indent(sb, level, "}\n\n");
        }
        else
        {
            indent(sb, level, "#[inline]\n");
            indent(sb, level, "pub fn %s(&self) -> %s {\n",
                formatFunctionName(name),
                rustPrimitiveType);
            indent(sb, level + 1, "%s\n", rawConstValue);
            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