static void generateReadBuf(final Appendable writer, final ByteOrder byteOrder) throws IOException
    {
        indent(writer, 0, "#[derive(Clone, Copy, Debug, Default)]\n");
        indent(writer, 0, "pub struct %s<%s> {\n", READ_BUF_TYPE, BUF_LIFETIME);
        RustUtil.indent(writer, 1, "data: &%s [u8],\n", BUF_LIFETIME);
        indent(writer, 0, "}\n");

        // impl Reader...
        indent(writer, 0, "impl<%s> Reader<%1$s> for %2$s<%1$s> {\n", BUF_LIFETIME, READ_BUF_TYPE);
        indent(writer, 1, "#[inline]\n");
        indent(writer, 1, "fn get_buf(&self) -> &ReadBuf<%s> {\n", BUF_LIFETIME);
        indent(writer, 2, "self\n");
        indent(writer, 1, "}\n");
        indent(writer, 0, "}\n");

        // impl ReadBuf ...
        indent(writer, 0, "#[allow(dead_code)]\n");
        indent(writer, 0, "impl<%s> %s<%s> {\n", BUF_LIFETIME, READ_BUF_TYPE, BUF_LIFETIME);
        indent(writer, 1, "#[inline]\n");
        indent(writer, 1, "pub fn new(data: &%s [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(crate) fn get_bytes_at<const N: usize>(slice: &[u8], index: usize) -> [u8; N] {\n");
        indent(writer, 2, "slice[index..index+N].try_into().expect(\"slice with incorrect length\")\n");
        indent(writer, 1, "}\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, 0, "\n");
        indent(writer, 1, "#[inline]\n");
        indent(writer, 1, "pub fn get_u8_at(&self, index: usize) -> u8 {\n");
        indent(writer, 2, "self.data[index]\n");
        indent(writer, 1, "}\n");

        for (final String primitiveType : uniquePrimitiveTypes)
        {
            // get_<primitive>_at
            indent(writer, 0, "\n");
            indent(writer, 1, "#[inline]\n");
            indent(writer, 1, "pub fn get_%1$s_at(&self, index: usize) -> %1$s {\n", primitiveType);
            indent(writer, 2, "%s::from_%s_bytes(Self::get_bytes_at(self.data, index))\n", primitiveType, endianness);
            indent(writer, 1, "}\n");
        }

        // get_slice_at
        indent(writer, 0, "\n");
        indent(writer, 1, "#[inline]\n");
        indent(writer, 1, "pub fn get_slice_at(&self, index: usize, len: usize) -> &[u8] {\n");
        indent(writer, 2, "&self.data[index..index+len]\n");
        indent(writer, 1, "}\n\n");

        writer.append("}\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