StreamPeerGZIP
实验性: This class may be changed or removed in future versions.
继承: StreamPeer
< RefCounted
< Object
A stream peer that handles GZIP and deflate compression/decompression.
描述
This class allows to compress or decompress data using GZIP/deflate in a streaming fashion. This is particularly useful when compressing or decompressing files that have to be sent through the network without needing to allocate them all in memory.
After starting the stream via start_compression
(or start_decompression
), calling StreamPeer.put_partial_data
on this stream will compress (or decompress) the data, writing it to the internal buffer. Calling StreamPeer.get_available_bytes
will return the pending bytes in the internal buffer, and StreamPeer.get_partial_data
will retrieve the compressed (or decompressed) bytes from it. When the stream is over, you must call finish
to ensure the internal buffer is properly flushed (make sure to call StreamPeer.get_available_bytes
on last time to check if more data needs to be read after that).
方法
void | clear ( ) |
Error | finish ( ) |
Error | start_compression ( use_deflate: bool = false, buffer_size: int = 65535 ) |
Error | start_decompression ( use_deflate: bool = false, buffer_size: int = 65535 ) |
方法说明
void
clear ( )
Clears this stream, resetting the internal state.
Error finish ( )
Finalizes the stream, compressing or decompressing any buffered chunk left.
Error start_compression ( use_deflate: bool
= false, buffer_size: int
= 65535 )
Start the stream in compression mode with the given buffer_size
, if use_deflate
is true
uses deflate instead of GZIP.
Error start_decompression ( use_deflate: bool
= false, buffer_size: int
= 65535 )
Start the stream in decompression mode with the given buffer_size
, if use_deflate
is true
uses deflate instead of GZIP.
本方法通常需要用户覆盖才能生效。
本方法无副作用,不会修改该实例的任何成员变量。
本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。
本方法用于构造某个类型。
调用本方法无需实例,可直接使用类名进行调用。
本方法描述的是使用本类型作为左操作数的有效运算符。
这个值是由下列位标志构成位掩码的整数。
无返回值。