-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add static compression helper methods #44793
Comments
|
Things to consider:
|
There is also some past discussions at #2236 for reference. Though, I'm not in favor of the proposal above, for the reason that the API I would prefer that we follow what was suggested by @stephentoub in this issue comment with low level encoders taking a Span-in/Span-out but I'm also more interested of having raw level wrapper of compression libraries that can expose the specificities of each (e.g compression level between libraries can be different, level vs time can be an important factor as well) so that we can build higher level richer API (like the encoders or specific scenarios). |
Is this not a dupe of #39327 ? |
@FiniteReality #39327 does not have static methods. I think that's important to reach the best convenience possible. |
I do prefer also a low level API, something like that: public partial class Deflate
{
public static OperationStatus CompressData(ReadOnlySpan<byte> data, Span<byte> compressedData, CompressionLevel compressionLevel = CompressionLevel.Default) => throw null;
public static void CompressData(ReadOnlySpan<byte> data, IBufferWriter<byte> bufferWritter, CompressionLevel compressionLevel = CompressionLevel.Default) => throw null;
public static void DecompressData(ReadOnlySpan<byte>compressedData, IBufferWriter<byte> bufferWritter) => throw null;
public static OperationStatus DecompressData(ReadOnlySpan<byte>compressedData, Span<byte> destination, out int bytesConsumed, out int bytesWritten) => throw null;
} |
Problem:
Compressing data currently requires the use of streams. For example:
This code is alright. It could be more convenient, though:
Benefits:
There is a related proposal that addresses this in a different way: #39327 That proposal seems to be about avoiding allocations while this proposal is more about improving convenience.
Proposal:
Use this pattern for all built-in compression types:
It does not get more convenient than this. That is the primary goal.
The text was updated successfully, but these errors were encountered: