RecordBlock

Struct RecordBlock 

Source
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 size

Implementations§

Source§

impl RecordBlock

Source

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 block
  • block_size - Maximum size of the block in bytes
§Returns

A new empty RecordBlock instance

Source

pub fn n_records(&self) -> usize

Returns the number of records in this block

§Returns

The number of records currently stored in this block

Source

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());
}
Source

pub fn clear(&mut self)

Clears all data from the block

This method resets the block to an empty state, clearing all vectors and resetting the index to 0. This is typically used when reusing a block for reading a new block from a file.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V