private static void generateBitSetEncoder(
        final StringBuilder sb,
        final int level,
        final Token bitsetToken,
        final String name) throws IOException
    {
        final Encoding encoding = bitsetToken.encoding();
        final String rustPrimitiveType = rustTypeName(encoding.primitiveType());
        final String referencedName = bitsetToken.referencedName();
        final String structTypeName = format("%s::%s",
            toLowerSnakeCase(referencedName == null ? bitsetToken.name() : referencedName),
            formatStructName(bitsetToken.applicableTypeName()));
        indent(sb, level, "#[inline]\n");
        indent(sb, level, "pub fn %s(&mut self, value: %s) {\n", formatFunctionName(name), structTypeName);

        // NB: must create variable 'offset' before calling mutable self.get_buf_mut()
        indent(sb, level + 1, "let offset = self.%s;\n", getBufOffset(bitsetToken));
        indent(sb, level + 1, "self.get_buf_mut().put_%s_at(offset, value.0)\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