Struct bam::bgzip::Block [−][src]
pub struct Block { /* fields omitted */ }Expand description
A bgzip block, that can contain compressed, uncompressed data, or both.
You can extend uncompressed data using extend_contents, and and then compress the block using compress.
Implementations
Resets compressed data, if present. This function is needed if you want to update uncompressed contents.
Makes a block a compressed block with empty contents. It is different from reset as the block will have valid compressed data and can be written.
Extends uncompressed contents and returns the number of consumed bytes. The only case when
the number of consumed bytes is less then the size of the buf is when the content size
reaches maximum size MAX_BLOCK_SIZE.
However, it is not recommended to fill the
contents completely to MAX_BLOCK_SIZE
as the compressed size may become too big
(bigger than MAX_COMPRESSED_SIZE).
This function panics if the block contains compressed data (see reset_compression).
Returns the size of the uncompressed data (this works even if the block was not decompressed).
Returns the size of the compressed data. If the block was not compressed, the function returns zero. Note, that the compressed size does not include header and footer of the bgzip block.
Returns the size of the block (sum size of compressed data, header and footer). Returns None if the block was not compressed yet.
Returns the state of the block.
Compresses block contents. Note that if the contents are empty, the function will compress them into a valid block (see make_empty).
If the compressed size is bigger than
MAX_COMPRESSED_SIZE, the function returns
WriteZero. Function panics if the block is already compressed.
Writes the compressed block to stream. The function panics if the block was not compressed.
Reads the compressed contents from stream. Panics if the block is non-empty
(consider using reset).
Decompresses block contents. This function panics if the block was already decompressed or if the block is empty.
Access uncompressed data.
Access compressed data (without header and footer). Panics if the block is not compressed.
Returns CRC32 hash of the uncompressed data. Panics if the block is not compressed.
Truncates uncompressed contents on first_size,
writes the remaining data into second_part, and
returns the number of bytes written into second_part.
Panics, if the second_part is not big enough.
The function trims the contents of self, and returns the second half in a new Block.
The function panics if the initial block was compressed
or its uncompressed size is less than 2 bytes.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Block
impl UnwindSafe for Block
Blanket Implementations
Mutably borrows from an owned value. Read more
