private static void generateSingleBitSet(
        final String bitSetType,
        final List<Token> tokens,
        final Appendable writer) throws IOException
    {
        final Token beginToken = tokens.get(0);
        final String rustPrimitiveType = rustTypeName(beginToken.encoding().primitiveType());
        indent(writer, 0, "#[derive(Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]\n");
        indent(writer, 0, "pub struct %s(pub %s);\n", bitSetType, rustPrimitiveType);
        indent(writer, 0, "impl %s {\n", bitSetType);
        indent(writer, 1, "#[inline]\n");
        indent(writer, 1, "pub fn new(value: %s) -> Self {\n", rustPrimitiveType);
        indent(writer, 2, "%s(value)\n", bitSetType);
        indent(writer, 1, "}\n\n");

        indent(writer, 1, "#[inline]\n");
        indent(writer, 1, "pub fn clear(&mut self) -> &mut Self {\n");
        indent(writer, 2, "self.0 = 0;\n");
        indent(writer, 2, "self\n");
        indent(writer, 1, "}\n");

        for (final Token token : tokens)
        {
            if (Signal.CHOICE != token.signal())
            {
                continue;
            }

            final String choiceName = formatFunctionName(token.name());
            final Encoding encoding = token.encoding();
            final String choiceBitIndex = encoding.constValue().toString();

            indent(writer, 0, "\n");
            indent(writer, 1, "#[inline]\n");
            indent(writer, 1, "pub fn get_%s(&self) -> bool {\n", choiceName);
            indent(writer, 2, "0 != self.0 & (1 << %s)\n", choiceBitIndex);
            indent(writer, 1, "}\n\n");

            indent(writer, 1, "#[inline]\n");
            indent(writer, 1, "pub fn set_%s(&mut self, value: bool) -> &mut Self {\n", choiceName);
            indent(writer, 2, "self.0 = if value {\n");
            indent(writer, 3, "self.0 | (1 << %s)\n", choiceBitIndex);
            indent(writer, 2, "} else {\n");
            indent(writer, 3, "self.0 & !(1 << %s)\n", choiceBitIndex);
            indent(writer, 2, "};\n");
            indent(writer, 2, "self\n");
            indent(writer, 1, "}\n");
        }
        indent(writer, 0, "}\n");

        indent(writer, 0, "impl core::fmt::Debug for %s {\n", bitSetType);
        indent(writer, 1, "#[inline]\n");
        indent(writer, 1, "fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {\n");
        indent(writer, 2, "write!(fmt, \"%s[", bitSetType);

        final StringBuilder builder = new StringBuilder();
        final StringBuilder arguments = new StringBuilder();
        boolean comma = false;
        for (final Token token : tokens)
        {
            if (Signal.CHOICE != token.signal())
            {
                continue;
            }

            final String choiceName = formatFunctionName(token.name());
            final String choiceBitIndex = token.encoding().constValue().toString();

            if (comma)
            {
                builder.append(",");
            }

            builder.append(choiceName).append("(").append(choiceBitIndex).append(")={}");
            arguments.append("self.get_").append(choiceName).append("(),");
            comma = true;
        }

        writer.append(builder.toString()).append("]\",\n");
        indent(writer, 3, arguments + ")\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