static void generateWriteBuf(final Writer writer, final ByteOrder byteOrder) throws IOException
    {
        indent(writer, 0, "\n");
        indent(writer, 0, "#[derive(Debug, Default)]\n");
        indent(writer, 0, "pub struct %s<%s> {\n", WRITE_BUF_TYPE, BUF_LIFETIME);
        indent(writer, 1, "data: &%s mut [u8],\n", BUF_LIFETIME);
        indent(writer, 0, "}\n");

        indent(writer, 0, "impl<%s> %s<%s> {\n", BUF_LIFETIME, WRITE_BUF_TYPE, BUF_LIFETIME);
        indent(writer, 1, "pub fn new(data: &%s mut [u8]) -> Self {\n", BUF_LIFETIME);
        indent(writer, 2, "Self { data }\n");
        indent(writer, 1, "}\n\n");

        indent(writer, 1, "#[inline]\n");
        indent(writer, 1,
            "pub fn put_bytes_at<const COUNT: usize>(&mut self, index: usize, bytes: &[u8; COUNT]) -> usize {\n");
        indent(writer, 2, "self.data[index..index + COUNT].copy_from_slice(bytes);\n");
        indent(writer, 2, "COUNT\n");
        indent(writer, 1, "}\n\n");

        final LinkedHashSet<String> uniquePrimitiveTypes
            = new LinkedHashSet<>(TYPE_NAME_BY_PRIMITIVE_TYPE_MAP.values());
        final String endianness = byteOrder == LITTLE_ENDIAN ? "le" : "be";

        uniquePrimitiveTypes.remove("u8");
        indent(writer, 1, "#[inline]\n");
        indent(writer, 1, "pub fn put_u8_at(&mut self, index: usize, value: u8) {\n");
        indent(writer, 2, "self.data[index] = value;\n");
        indent(writer, 1, "}\n\n");

        for (final String primitiveType : uniquePrimitiveTypes)
        {
            // put_<primitive>_at
            indent(writer, 1, "#[inline]\n");
            indent(writer, 1, "pub fn put_%1$s_at(&mut self, index: usize, value: %1$s) {\n", primitiveType);
            indent(writer, 2, "self.put_bytes_at(index, &%s::to_%s_bytes(value));\n", primitiveType, endianness);
            indent(writer, 1, "}\n\n");
        }

        // put_slice_at
        indent(writer, 1, "#[inline]\n");
        indent(writer, 1, "pub fn put_slice_at(&mut self, index: usize, src: &[u8]) -> usize {\n");
        indent(writer, 2, "let len = src.len();\n");
        indent(writer, 2, "let dest = self.data.split_at_mut(index).1.split_at_mut(len).0;\n");
        indent(writer, 2, "dest.clone_from_slice(src);\n");
        indent(writer, 2, "len\n");
        indent(writer, 1, "}\n");
        indent(writer, 0, "}\n");

        // impl From<WriteBuf> for &[u8]
        indent(writer, 0, "impl<%s> From<&%1$s mut %2$s<%1$s>> for &%1$s mut [u8] {\n", BUF_LIFETIME, WRITE_BUF_TYPE);
        indent(writer, 1, "#[inline]\n");
        indent(writer, 1, "fn from(buf: &%s mut %2$s<%1$s>) -> &%1$s mut [u8] {\n", BUF_LIFETIME, WRITE_BUF_TYPE);
        indent(writer, 2, "buf.data\n");
        indent(writer, 1, "}\n");
        indent(writer, 0, "}\n\n");
    }
Create a new 'lib.rs' for the library being generated.

@param outputManager     for generating the codecs to.
@param byteOrder         for the Encoding.
@param schemaVersionType for acting_version type.
sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/rust/LibRsDef.java