Skip to main content

GziIndex

Struct GziIndex 

Source
pub struct GziIndex {
    pub entries: Vec<(u64, u64)>,
}
Expand description

A gzip index for BGZF-compressed files.

Maps uncompressed byte positions to compressed file positions, enabling efficient seeking in compressed files.

§Format

Binary format (little-endian):

  • First 8 bytes: number of index entries (u64)
  • Following bytes: pairs of (compressed_offset, uncompressed_offset) as u64

§Example

use fastx::gzi::GziIndex;
use std::path::Path;

let index = GziIndex::from_path(Path::new("data.fasta.gz.gzi")).unwrap();
let compressed_offset = index.get_compressed_offset(10000).unwrap();

Fields§

§entries: Vec<(u64, u64)>

Sorted entries: (compressed_offset, uncompressed_offset)

Implementations§

Source§

impl GziIndex

Source

pub fn from_path(path: &Path) -> Result<Self>

Load a .gzi index from a file.

§Arguments
  • path - Path to the .gzi index file
§Returns
  • Ok(GziIndex) - The parsed index
  • Err(io::Error) - If the file cannot be read or the format is invalid
Source

pub fn from_bytes(buffer: &[u8]) -> Result<Self>

Load a .gzi index from raw bytes.

§Arguments
  • buffer - Byte slice containing .gzi formatted data
§Returns
  • Ok(GziIndex) - The parsed index
  • Err(io::Error) - If the data is too short or the format is invalid
Source

pub fn get_compressed_offset(&self, uncompressed_offset: u64) -> Option<u64>

Get the compressed offset for a given uncompressed position.

Source

pub fn get_uncompressed_offset(&self, compressed_offset: u64) -> Option<u64>

Get the uncompressed offset for a given compressed position.

Source

pub fn len(&self) -> usize

Get the number of index entries.

Source

pub fn is_empty(&self) -> bool

Check if the index is empty.

Source

pub fn entries(&self) -> &[(u64, u64)]

Get a reference to all entries.

Trait Implementations§

Source§

impl Clone for GziIndex

Source§

fn clone(&self) -> GziIndex

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GziIndex

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.