# Compressor

class asdf.extension.Compressor

  Bases: `abc.ABC`

  Abstract base class for plugins that compress binary data.

  Implementing classes must provide the `labels` property, and at least one of the `compress()` and `decompress()` methods. May also provide a constructor.

  Attributes Summary

  `label` | Get the 4-byte label identifying this compression

  Methods Summary

  `compress`(data, **kwargs) | Compress `data`, yielding the results.
  `decompress`(data, out, **kwargs) | Decompress `data`, writing the result into `out`.

  Attributes Documentation

  label

    Get the 4-byte label identifying this compression

    Returns
      label bytes

        The compression label

  Methods Documentation

  compress(data, **kwargs)

    Compress `data`, yielding the results. The yield may be block-by-block, or all at once.

    Parameters
      data memoryview

        The data to compress. Must be contiguous and 1D, with the underlying `itemsize` preserved.

      **kwargs

        Keyword arguments to be passed to the underlying compression function

    Yields
      compressed bytes-like

        A block of compressed data

  decompress(data, out, **kwargs)

    Decompress `data`, writing the result into `out`.

    Parameters
      data Iterable of bytes-like

        An Iterable of bytes-like objects containing chunks of compressed data.

      out read-write bytes-like

        A contiguous, 1D output array, of equal or greater length than the decompressed data.

      **kwargs

        Keyword arguments to be passed to the underlying decompression function

    Returns
      nbytes int

        The number of bytes written to `out`