Skip to main content

DeflateIndex

Struct DeflateIndex 

Source
pub struct DeflateIndex { /* private fields */ }
Expand description

An in-memory random-access index for a DEFLATE-based stream.

Implementations§

Source§

impl DeflateIndex

Source

pub fn new() -> Self

Returns an empty index.

Source

pub const fn kind(&self) -> IndexKind

Returns the source/container provenance recorded by this index.

Source

pub const fn set_kind(&mut self, kind: IndexKind)

Records source/container provenance.

Source

pub const fn compressed_size(&self) -> Option<u64>

Returns the known compressed source size in bytes.

Source

pub const fn set_compressed_size(&mut self, size: Option<u64>)

Records the compressed source size, or clears it when unknown.

Source

pub const fn uncompressed_size(&self) -> Option<u64>

Returns the known total decompressed size in bytes.

Source

pub const fn set_uncompressed_size(&mut self, size: Option<u64>)

Records the total decompressed size, or clears it when unknown.

Source

pub const fn checkpoint_spacing(&self) -> Option<u64>

Returns the target decompressed checkpoint spacing, when recorded.

Source

pub const fn set_checkpoint_spacing(&mut self, spacing: Option<u64>)

Records the target decompressed checkpoint spacing.

Source

pub const fn total_line_count(&self) -> Option<u64>

Returns the total line count carried by the source index.

Source

pub const fn set_total_line_count(&mut self, count: Option<u64>)

Records the total line count, or clears it when unknown.

Source

pub fn push( &mut self, checkpoint: Checkpoint, window: StoredWindow, ) -> Result<(), IndexError>

Appends a checkpoint and its predecessor window.

Ordering is not checked here; call Self::validate once the index is complete.

Source

pub fn checkpoint_count(&self) -> usize

Returns the number of checkpoints.

Source

pub fn is_empty(&self) -> bool

Returns whether the index holds no checkpoints.

Source

pub fn checkpoints(&self) -> &[Checkpoint]

Returns the checkpoints in order.

Source

pub const fn windows(&self) -> &WindowMap

Returns the stored predecessor windows.

Source

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

Returns the last checkpoint at or before uncompressed_offset.

Source

pub fn checkpoint_at_or_before_line(&self, line: u64) -> Option<&Checkpoint>

Returns the latest checkpoint proven not to be after zero-based line’s start.

A line offset is the number of newline bytes preceding a checkpoint. A checkpoint with the same offset as line may already be inside that line, so targets after line zero resume from the last checkpoint with a strictly smaller line offset. Line zero resumes from a checkpoint at decoded offset zero. This returns None unless the index has a total line count and every checkpoint is annotated, because selecting from partially annotated metadata could skip past the requested line.

Source

pub fn write_native(&self, writer: &mut impl Write) -> Result<(), IndexError>

Writes this index in the crate’s native versioned format.

The native format is the only one that round-trips every field, including line offsets and compressed window payloads.

Source

pub fn read_native(reader: &mut impl Read) -> Result<Self, IndexError>

Reads an index written by Self::write_native.

Source

pub fn read_native_with_options( reader: &mut impl Read, options: IndexReadOptions, ) -> Result<Self, IndexError>

Reads a native index using explicit untrusted-input limits.

Source

pub fn write_gzidx(&self, writer: &mut impl Write) -> Result<(), IndexError>

Writes this index in indexed_gzip GZIDX version 1 format.

Every non-empty window is written as exactly WINDOW_SIZE bytes.

Source

pub fn read_gzidx( reader: &mut impl Read, archive_size: Option<u64>, ) -> Result<Self, IndexError>

Reads an indexed_gzip GZIDX index, accepting versions 0 and 1.

When archive_size is Some, it must equal the compressed size stored in the index header.

Source

pub fn read_gzidx_with_options( reader: &mut impl Read, archive_size: Option<u64>, options: IndexReadOptions, ) -> Result<Self, IndexError>

Reads a GZIDX index using explicit untrusted-input limits.

Source

pub fn write_gzi(&self, writer: &mut impl Write) -> Result<(), IndexError>

Writes this index in htslib BGZF .gzi format.

Only indexes whose checkpoints all sit on independent member or block boundaries can be represented; a checkpoint carrying a predecessor window or a non-byte-aligned offset is refused, because reimporting it would install an empty window and seek to the wrong place.

Source

pub fn read_gzi( reader: &mut impl Read, archive_size: Option<u64>, ) -> Result<Self, IndexError>

Reads an htslib BGZF .gzi index.

The format does not record the uncompressed size, so the result leaves it unknown. archive_size, when supplied, is recorded as the compressed size.

Source

pub fn read_gzi_with_options( reader: &mut impl Read, archive_size: Option<u64>, options: IndexReadOptions, ) -> Result<Self, IndexError>

Reads a .gzi index using explicit untrusted-input limits.

Source

pub fn write_gztool( &self, writer: &mut impl Write, lines: WithLines, ) -> Result<(), IndexError>

Writes this index in gztool format.

WithLines::Yes writes version 1 with per-point line counters; WithLines::No writes version 0 and omits them. Windows are stored zlib-compressed, as gztool does.

Source

pub fn read_gztool( reader: &mut impl Read, archive_size: Option<u64>, ) -> Result<Self, IndexError>

Reads a complete gztool index of either version.

gztool does not record the compressed archive size, so archive_size, when supplied, is recorded as the compressed size.

Source

pub fn read_gztool_with_options( reader: &mut impl Read, archive_size: Option<u64>, options: IndexReadOptions, ) -> Result<Self, IndexError>

Reads a gztool index using explicit untrusted-input limits.

Source

pub fn validate(&self) -> Result<(), IndexError>

Checks the index invariants.

Compressed offsets must increase strictly and decompressed offsets must not decrease. Every non-empty window must be exactly WINDOW_SIZE bytes, and offsets must fall inside the recorded sizes when those are known.

Trait Implementations§

Source§

impl Clone for DeflateIndex

Source§

fn clone(&self) -> DeflateIndex

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for DeflateIndex

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for DeflateIndex

Source§

fn default() -> DeflateIndex

Returns the “default value” for a type. Read more
Source§

impl Eq for DeflateIndex

Source§

impl PartialEq for DeflateIndex

Source§

fn eq(&self, other: &DeflateIndex) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DeflateIndex

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.