crypto_compClass
Lua interface to compression algorithms, served by the asynchronous compression API on every supported kernel.
Each call waits for the operation to finish, a hardware engine included. The wait sleeps, so the class remains reserved to process context, and a stop does not end it: a thread whose call waits for an engine that never finishes cannot be stopped. Up to 6.14, an algorithm the kernel serves through scomp,lz4 and deflate among them,
refuses an input past 128 KiB with EINVAL and fails an output past 128 KiB whatever max_len
says, so lz4 raises EINVAL on incompressible data of 131072 bytes.
Not built where the kernel builds no user of its compression API, CONFIG_CRYPTO_ACOMP2.
Methods
| crypto_comp:algname () | Returns the driver-independent name of the algorithm the transform was allocated with. |
| crypto_comp:close () | Releases the transform. |
| crypto_comp:compress (data, max_len) | Compresses data. |
| crypto_comp:decompress (data, max_len) | Decompresses data. |
Methods in detail
- crypto_comp:algname ()
-
Returns the driver-independent name of the algorithm the transform was allocated with.
Returns
- crypto_comp:close ()
-
Releases the transform.
A to-be-closed variable holding the object releases it the same way. Calling it again does
nothing, and every other method raises “closed object” afterwards.
Returns
-
nil
- crypto_comp:compress (data, max_len)
-
Compresses data.
Parameters
- data string input data
- max_len integer maximum size of compressed output
Returns
-
string
compressed data
Raises
on compression failure, “not enough memory” when one kmalloc block cannot be allocated, always pastKMALLOC_MAX_SIZE - crypto_comp:decompress (data, max_len)
-
Decompresses data.
Parameters
- data string compressed input
- max_len integer maximum size of decompressed output
Returns
-
string
decompressed data
Raises
on decompression failure, “not enough memory” when one kmalloc block cannot be allocated, always pastKMALLOC_MAX_SIZE