pub struct DeflateIndex { /* private fields */ }Expand description
An in-memory random-access index for a DEFLATE-based stream.
Implementations§
Source§impl DeflateIndex
impl DeflateIndex
Sourcepub const fn kind(&self) -> IndexKind
pub const fn kind(&self) -> IndexKind
Returns the source/container provenance recorded by this index.
Sourcepub const fn compressed_size(&self) -> Option<u64>
pub const fn compressed_size(&self) -> Option<u64>
Returns the known compressed source size in bytes.
Sourcepub const fn set_compressed_size(&mut self, size: Option<u64>)
pub const fn set_compressed_size(&mut self, size: Option<u64>)
Records the compressed source size, or clears it when unknown.
Sourcepub const fn uncompressed_size(&self) -> Option<u64>
pub const fn uncompressed_size(&self) -> Option<u64>
Returns the known total decompressed size in bytes.
Sourcepub const fn set_uncompressed_size(&mut self, size: Option<u64>)
pub const fn set_uncompressed_size(&mut self, size: Option<u64>)
Records the total decompressed size, or clears it when unknown.
Sourcepub const fn checkpoint_spacing(&self) -> Option<u64>
pub const fn checkpoint_spacing(&self) -> Option<u64>
Returns the target decompressed checkpoint spacing, when recorded.
Sourcepub const fn set_checkpoint_spacing(&mut self, spacing: Option<u64>)
pub const fn set_checkpoint_spacing(&mut self, spacing: Option<u64>)
Records the target decompressed checkpoint spacing.
Sourcepub const fn total_line_count(&self) -> Option<u64>
pub const fn total_line_count(&self) -> Option<u64>
Returns the total line count carried by the source index.
Sourcepub const fn set_total_line_count(&mut self, count: Option<u64>)
pub const fn set_total_line_count(&mut self, count: Option<u64>)
Records the total line count, or clears it when unknown.
Sourcepub fn push(
&mut self,
checkpoint: Checkpoint,
window: StoredWindow,
) -> Result<(), IndexError>
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.
Sourcepub fn checkpoint_count(&self) -> usize
pub fn checkpoint_count(&self) -> usize
Returns the number of checkpoints.
Sourcepub fn checkpoints(&self) -> &[Checkpoint]
pub fn checkpoints(&self) -> &[Checkpoint]
Returns the checkpoints in order.
Sourcepub fn checkpoint_at_or_before(
&self,
uncompressed_offset: u64,
) -> Option<&Checkpoint>
pub fn checkpoint_at_or_before( &self, uncompressed_offset: u64, ) -> Option<&Checkpoint>
Returns the last checkpoint at or before uncompressed_offset.
Sourcepub fn checkpoint_at_or_before_line(&self, line: u64) -> Option<&Checkpoint>
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.
Sourcepub fn write_native(&self, writer: &mut impl Write) -> Result<(), IndexError>
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.
Sourcepub fn read_native(reader: &mut impl Read) -> Result<Self, IndexError>
pub fn read_native(reader: &mut impl Read) -> Result<Self, IndexError>
Reads an index written by Self::write_native.
Sourcepub fn read_native_with_options(
reader: &mut impl Read,
options: IndexReadOptions,
) -> Result<Self, IndexError>
pub fn read_native_with_options( reader: &mut impl Read, options: IndexReadOptions, ) -> Result<Self, IndexError>
Reads a native index using explicit untrusted-input limits.
Sourcepub fn write_gzidx(&self, writer: &mut impl Write) -> Result<(), IndexError>
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.
Sourcepub fn read_gzidx(
reader: &mut impl Read,
archive_size: Option<u64>,
) -> Result<Self, IndexError>
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.
Sourcepub fn read_gzidx_with_options(
reader: &mut impl Read,
archive_size: Option<u64>,
options: IndexReadOptions,
) -> Result<Self, IndexError>
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.
Sourcepub fn write_gzi(&self, writer: &mut impl Write) -> Result<(), IndexError>
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.
Sourcepub fn read_gzi(
reader: &mut impl Read,
archive_size: Option<u64>,
) -> Result<Self, IndexError>
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.
Sourcepub fn read_gzi_with_options(
reader: &mut impl Read,
archive_size: Option<u64>,
options: IndexReadOptions,
) -> Result<Self, IndexError>
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.
Sourcepub fn write_gztool(
&self,
writer: &mut impl Write,
lines: WithLines,
) -> Result<(), IndexError>
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.
Sourcepub fn read_gztool(
reader: &mut impl Read,
archive_size: Option<u64>,
) -> Result<Self, IndexError>
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.
Sourcepub fn read_gztool_with_options(
reader: &mut impl Read,
archive_size: Option<u64>,
options: IndexReadOptions,
) -> Result<Self, IndexError>
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.
Sourcepub fn validate(&self) -> Result<(), IndexError>
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
impl Clone for DeflateIndex
Source§fn clone(&self) -> DeflateIndex
fn clone(&self) -> DeflateIndex
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more