Deflate

public class Deflate : DecompressionAlgorithm
extension Deflate: CompressionAlgorithm

Provides functions for compression and decompression for Deflate algorithm.

  • Decompresses data using Deflate algortihm.

    Note

    This function is specification compliant.

    Throws

    DeflateError if unexpected byte (bit) sequence was encountered in data. It may indicate that either data is damaged or it might not be compressed with Deflate at all.

    Declaration

    Swift

    public static func decompress(data: Data) throws -> Data

    Parameters

    data

    Data compressed with Deflate.

    Return Value

    Decompressed data.

  • Compresses data with Deflate algortihm.

    Note

    Currently, SWCompression creates only one block for all data and the block can either be uncompressed or compressed with static Huffman encoding. Choice of one block type or the other depends on bytes’ statistics of data. However, if data size is greater than 65535 (the maximum value stored in 2 bytes), then static Huffman block will be created.

    Declaration

    Swift

    public static func compress(data: Data) -> Data

    Parameters

    data

    Data to compress.