pub struct Decompressor<T> where
    T: NumberLike
{ /* private fields */ }
Expand description

Converts compressed bytes into Flags, ChunkMetadata, and vectors of numbers.

You can use the decompressor very easily:

use q_compress::Decompressor;

let my_bytes = vec![113, 99, 111, 33, 3, 0, 46]; // the simplest possible .qco file; empty
let decompressor = Decompressor::<i32>::default();
let nums = decompressor.simple_decompress(my_bytes).expect("decompression"); // returns Vec<i32>

You can also get full control over the decompression process:

use q_compress::{BitReader, Decompressor};

let my_bytes = vec![113, 99, 111, 33, 3, 0, 46]; // the simplest possible .qco file; empty
let mut reader = BitReader::from(my_bytes);
let decompressor = Decompressor::<i32>::default();

let flags = decompressor.header(&mut reader).expect("header failure");
while let Some(chunk_meta) = decompressor.chunk_metadata(&mut reader, &flags).expect("chunk meta failure") {
  let nums = decompressor.chunk_body(&mut reader, &flags, &chunk_meta).expect("chunk body failure");
}
// We don't need to explicitly read the footer because `.chunk_metadata()`
// returns `None` when it reaches the footer byte.

Implementations

Creates a new decompressor, given a DecompressorConfig. This config has nothing to do with Flags, which will be parsed out of a .qco file’s header.

Reads the header, returning its Flags. Will return an error if the reader is not byte-aligned, if the reader runs out of data, if the data type byte does not agree, if the flags are from a newer, incompatible version of q_compress, or if any corruptions are found.

Reads a ChunkMetadata, returning it. Will return None if it instead finds a termination footer (indicating end of the .qco file). Will return an error if the reader is not byte-aligned, the reader runs out of data, or any corruptions are found.

Typically one would pass in the Flags obtained from an earlier .header() call.

Reads a chunk body, returning it as a vector of numbers. Will return an error if the reader is not byte-aligned, the reader runs out of data, or any corruptions are found.

Typically one would pass in the Flags obtained from an earlier .header() call and the ChunkMetadata obtained from an earlier .chunk_metadata() call.

Reads a ChunkMetadata and the chunk body into a vector of numbers, returning both. Will return None if it instead finds a termination footer (indicating end of the .qco file). Will return an error if the reader is not byte-aligned, the reader runs out of data, or any corruptions are found.

The same effect can be achieved via .chunk_metadata() and .chunk_body().

Takes in compressed bytes and returns a vector of numbers. Will return an error if there are any compatibility, corruption, or insufficient data issues.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.