Class LzmaUtilityAsync
Compression utility class for LZMAing data using async/await. Uses Task.Run
to call the synchronous LZMA SDK:
Not the best thing to do, I know... But the LZMA SDK doesn't have an async API yet, and compression is usually a high-latency,
CPU bound op; that's why this deserves a dedicated thread via Task.Run
Implements the ICompressionUtilityAsync interface.
Inheritance
Implements
Namespace: GlitchedPolygons.Services.CompressionUtility
Assembly: GlitchedPolygons.Services.CompressionUtility.dll
Syntax
public class LzmaUtilityAsync : object, ICompressionUtilityAsync
Methods
| Improve this Doc View SourceCompress(Byte[], CompressionSettings)
Compresses the specified bytes using LZMA.
Declaration
public Task<byte[]> Compress(byte[] bytes, CompressionSettings compressionSettings)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | bytes | The |
CompressionSettings | compressionSettings | The desired CompressionSettings. |
Returns
Type | Description |
---|---|
Task<System.Byte[]> | The compressed |
Compress(String, Encoding)
Compresses the specified string
using LZMA and CompressionSettings.Default
.
Declaration
public Task<string> Compress(string text, Encoding encoding = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The |
Encoding | encoding | The encoding to use. Can be |
Returns
Type | Description |
---|---|
Task<System.String> | The compressed |
Decompress(Byte[], CompressionSettings)
Decompresses the specified bytes using LZMA and the CompressionSettings that have been used to originally compress the bytes.
Declaration
public Task<byte[]> Decompress(byte[] compressedBytes, CompressionSettings compressionSettings)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | compressedBytes | The compressed |
CompressionSettings | compressionSettings | The CompressionSettings that have been used to compress the bytes. |
Returns
Type | Description |
---|---|
Task<System.Byte[]> | The decompressed |
Decompress(String, Encoding)
Decompresses the specified compressed string
using LZMA and CompressionSettings.Default
.
Declaration
public Task<string> Decompress(string compressedString, Encoding encoding = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | compressedString | The compressed |
Encoding | encoding | The encoding to use. Can be |
Returns
Type | Description |
---|---|
Task<System.String> | The decompressed |