Data

extension Data
  • Calculate the CRC32 checksum of the receiver.

    Declaration

    Swift

    public func crc32(checksum: CRC32) -> CRC32

    Parameters

    checksum

    The starting seed.

    Return Value

    The checksum calculated from the bytes of the receiver and the starting seed.

  • Compress the output of provider and pass it to consumer.

    Declaration

    Swift

    public static func compress(size: Int64, bufferSize: Int, provider: Provider, consumer: Consumer) throws -> CRC32

    Parameters

    size

    The uncompressed size of the data to be compressed.

    bufferSize

    The maximum size of the compression buffer.

    provider

    A closure that accepts a position and a chunk size. Returns a Data chunk.

    consumer

    A closure that processes the result of the compress operation.

    Return Value

    The checksum of the processed content.

  • Decompress the output of provider and pass it to consumer.

    Declaration

    Swift

    public static func decompress(size: Int64, bufferSize: Int, skipCRC32: Bool,
                                  provider: Provider, consumer: Consumer) throws -> CRC32

    Parameters

    size

    The compressed size of the data to be decompressed.

    bufferSize

    The maximum size of the decompression buffer.

    skipCRC32

    Optional flag to skip calculation of the CRC32 checksum to improve performance.

    provider

    A closure that accepts a position and a chunk size. Returns a Data chunk.

    consumer

    A closure that processes the result of the decompress operation.

    Return Value

    The checksum of the processed content.

  • Declaration

    Swift

    static func compress(size: Int, bufferSize: Int,
                         provider: (_ position: Int, _ size: Int) throws -> Data,
                         consumer: Consumer) throws -> CRC32
  • Declaration

    Swift

    static func decompress(size: Int, bufferSize: Int, skipCRC32: Bool,
                           provider: (_ position: Int, _ size: Int) throws -> Data,
                           consumer: Consumer) throws -> CRC32