pub struct RecordBlock { /* private fields */ }Expand description
A container for a block of VBINSEQ records
The RecordBlock struct represents a single block of records read from a VBINSEQ file.
It stores the raw data for multiple records in vectors, allowing efficient iteration
over the records without copying memory for each record.
§Format Support (v0.7.0+)
- Supports reading records with optional sequence headers
- Handles both 2-bit and 4-bit nucleotide encodings
- Supports quality scores and paired sequences
- Compatible with both compressed and uncompressed blocks
The RecordBlock is reused when reading blocks sequentially from a file, with its
contents being cleared and replaced with each new block that is read.
§Examples
use binseq::vbq::MmapReader;
let reader = MmapReader::new("example.vbq").unwrap();
let mut block = reader.new_block(); // Create a block with appropriate sizeImplementations§
Source§impl RecordBlock
impl RecordBlock
Sourcepub fn new(bitsize: BitSize, block_size: usize) -> Self
pub fn new(bitsize: BitSize, block_size: usize) -> Self
Creates a new empty RecordBlock with the specified block size
The block size should match the one specified in the VBINSEQ file header
for proper operation. This is typically handled automatically when using
MmapReader::new_block().
§Parameters
bitsize- Bitsize of the records in the blockblock_size- Maximum size of the block in bytes
§Returns
A new empty RecordBlock instance
Sourcepub fn n_records(&self) -> usize
pub fn n_records(&self) -> usize
Returns the number of records in this block
§Returns
The number of records currently stored in this block
Sourcepub fn iter(&self) -> RecordBlockIter<'_> ⓘ
pub fn iter(&self) -> RecordBlockIter<'_> ⓘ
Returns an iterator over the records in this block
The iterator yields RefRecord instances that provide access to the record data
without copying the underlying data.
§Returns
An iterator over the records in this block
§Examples
use binseq::vbq::MmapReader;
use binseq::BinseqRecord;
let mut reader = MmapReader::new("example.vbq").unwrap();
let mut block = reader.new_block();
reader.read_block_into(&mut block).unwrap();
// Iterate over records in the block
for record in block.iter() {
println!("Record {}", record.index());
}