(
self,
encoding: str | None = None,
suppress_deflate_header: bool = False,
level: int | None = None,
wbits: int | None = None,
strategy: int | None = None,
executor: Executor | None = None,
max_sync_chunk_size: int | None = MAX_SYNC_CHUNK_SIZE,
)
| 192 | |
| 193 | class ZLibCompressor: |
| 194 | def __init__( |
| 195 | self, |
| 196 | encoding: str | None = None, |
| 197 | suppress_deflate_header: bool = False, |
| 198 | level: int | None = None, |
| 199 | wbits: int | None = None, |
| 200 | strategy: int | None = None, |
| 201 | executor: Executor | None = None, |
| 202 | max_sync_chunk_size: int | None = MAX_SYNC_CHUNK_SIZE, |
| 203 | ): |
| 204 | self._executor = executor |
| 205 | self._max_sync_chunk_size = max_sync_chunk_size |
| 206 | self._mode = ( |
| 207 | encoding_to_mode(encoding, suppress_deflate_header) |
| 208 | if wbits is None |
| 209 | else wbits |
| 210 | ) |
| 211 | self._zlib_backend: Final = ZLibBackendWrapper(ZLibBackend._zlib_backend) |
| 212 | |
| 213 | kwargs: CompressObjArgs = {} |
| 214 | kwargs["wbits"] = self._mode |
| 215 | if strategy is not None: |
| 216 | kwargs["strategy"] = strategy |
| 217 | if level is not None: |
| 218 | kwargs["level"] = level |
| 219 | self._compressor = self._zlib_backend.compressobj(**kwargs) |
| 220 | |
| 221 | def compress_sync(self, data: Buffer) -> bytes: |
| 222 | return self._compressor.compress(data) |
no test coverage detected