pylibschc.compressor
¶
User-facing compressor/decompressor functionality
- class pylibschc.compressor.CompressorDecompressor(*args, **kwargs)[source]¶
Bases:
object
A Compressor/Decompressor.
This wraps
pylibschc.libschc.CompressorDecompressor
for a more pythonic usage.- Parameters:
device (
pylibschc.device.Device
) – Device to be used for compression/decompression.
- device: pylibschc.device.Device¶
Device to be used for compression/decompression.
- input(data: bytes | BitArray, direction: Direction) bytes [source]¶
Decompress according to the compression rules of
CompressorDecompressor.device
.- Parameters:
data – The data to decompress.
direction – Direction to use for decompression.
- Raises:
TypeError – When
data
is not of the expected input type.ValueError – When direction is
pylibschc.libschc.Direction.BI
.
- Returns:
The decompressed data.
- Return type:
bytes
- output(data: bytes | BitArray, direction: Direction) Tuple[CompressionResult, BitArray] [source]¶
Compress according to the compression rules of
CompressorDecompressor.device
.- Parameters:
data – The data to compress.
direction – Direction to use for compression.
- Raises:
TypeError – When
data
is not of the expected input type.ValueError – When direction is
pylibschc.libschc.Direction.BI
.
- Returns:
Whether the packet was compressed or the uncompressed rule was used and the compressed packet as a
pylibschc.libschc.BitArray
.- Return type:
typing.Tuple
[pylibschc.libschc.CompressionResult
,pylibschc.libschc.BitArray
]