private static void generateFromPrimitiveForEnum(
        final String enumRustName,
        final String primitiveType,
        final List<Token> messageBody,
        final Appendable writer) throws IOException
    {
        indent(writer, 0, "impl From<%s> for %s {\n", primitiveType, enumRustName);
        indent(writer, 1, "#[inline]\n");
        indent(writer, 1, "fn from(v: %s) -> Self {\n", primitiveType);
        indent(writer, 2, "match v {\n");

        for (final Token token : messageBody)
        {
            final Encoding encoding = token.encoding();
            final String literal = generateRustLiteral(encoding.primitiveType(), encoding.constValue().toString());
            indent(writer, 3, "%s => Self::%s, \n", literal, token.name());
        }

        // default => NullVal
        indent(writer, 3, "_ => Self::NullVal,\n");
        indent(writer, 2, "}\n");
        indent(writer, 1, "}\n");
        indent(writer, 0, "}\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