The Compressor is responsible for compressing source data for placement into the Zip archive. The Zip format supports different types of compression methods, so many different Compressors can be created, as long as they conform to the behaviour.
Summary
Callbacks
Closes down the Compressor at end of input stream. This is called when the input has been fully read (hit EOF) or further data is otherwise no longer expected for the input. When called, the Compressor may take the opportunity to emit a final part of the data stream, flushing its internal buffers. The Compressor is expected to then have emitted the entire data stream that can be used to reconstruct the input.
Closes the compressor for good. All external resources should be released here; no further calls
will be made by the Encoder past this point. Prior to this call, close/1 should have been
invoked to mark the end of a previous stream, so the Compressor is not expected to emit any
further data.
Iterates the Compressor with the incoming data, compresses it and emits both the compressed data, and if necessary, an updated state.
Initialises a Compressor with the initialisation argument specified in Entries. If
such an argument was not specified then it should have been normalised to []. The
Compressor has the opportunity to emit the initial part of the data stream here.
Closes the internal compression stream for the previous item and re-opens the Compressor for
the next item. Functionally this would be identical to calling close/1 and open/1, but in
practice this callback is used to facilitate preservation of external resources that may
be costly to open and close when compressing many items.
Functions
Opens or resets the Compressor with the optional Initialisation Argument as specified in the Entry for a new file to be compressed.
Types
Callbacks
Closes down the Compressor at end of input stream. This is called when the input has been fully read (hit EOF) or further data is otherwise no longer expected for the input. When called, the Compressor may take the opportunity to emit a final part of the data stream, flushing its internal buffers. The Compressor is expected to then have emitted the entire data stream that can be used to reconstruct the input.
After close/1, the Encoder may call reset/2 again to compress a new input stream,
or call finalise/1 to close the Compressor down for good.
Closes the compressor for good. All external resources should be released here; no further calls
will be made by the Encoder past this point. Prior to this call, close/1 should have been
invoked to mark the end of a previous stream, so the Compressor is not expected to emit any
further data.
Iterates the Compressor with the incoming data, compresses it and emits both the compressed data, and if necessary, an updated state.
Initialises a Compressor with the initialisation argument specified in Entries. If
such an argument was not specified then it should have been normalised to []. The
Compressor has the opportunity to emit the initial part of the data stream here.
Closes the internal compression stream for the previous item and re-opens the Compressor for
the next item. Functionally this would be identical to calling close/1 and open/1, but in
practice this callback is used to facilitate preservation of external resources that may
be costly to open and close when compressing many items.
Functions
@spec build( compressor :: t() | nil, compression_method :: Packmatic.Manifest.Entry.method() ) :: {:ok, data(), compressor :: t()} | {:error, reason :: term()}
Opens or resets the Compressor with the optional Initialisation Argument as specified in the Entry for a new file to be compressed.
If the new Compression Method will result in the same Compressor being used again, then the existing
Compressor will be reset (via reset/2); this may result in the existing Compressor being
reused:
If the new Compression Method requires a different Compressor, for example the method was
:storebut is then changed to:deflatefor the subsequent entry, then the old Compressor will be closed and a new one will be opened in all scenarios.If the new Compression Method is resolved to the same Compressor, regardless of whether the Initialisation Argument is the same,
reset/2will be called and it would be up to the relevant callback module to handle this.
Called by Packmatic.Encoder.