Skip to main content

Module bytes

Module bytes 

Source
Expand description

Little-endian field reads and writes over a byte buffer.

Buffer ownership is bytes::Bytes — refcounted, cheaply sliced, which is what lets a BAM record borrow its decompressed BGZF block and a bbi item its decompressed data block without a copy. What is left is the typed-field half, and that is this file.

Every format here is little-endian and its readers refuse a byte-swapped file rather than swapping it, so there is no big-endian path. Reads copy rather than transmute: a record offset in a binary format is under no obligation to be aligned, and from_le_bytes over a copied array is both correct and, at these widths, free.

Bounds checking is not optional. Every read is checked and returns Error::Corrupt naming the offset, which is the same check the language emits anyway.

Structs§

LeBuf
The write half: an append-only buffer with the same field vocabulary, plus the patch-back-in-place the bbi writer needs for counts and offsets whose values are only known once what follows them has been built.
LeCursor
A forward cursor over a buffer, reading little-endian fields.