-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: Streaming API #4
Conversation
Hello Crauzer, and thanks a lot for the implementation! Could you please make The reason is: I would like to use your work in a pipeline of streams. With a hashing stream acting as a filter or facade. My implementation of such a Stream goes like this: public class HashingStream : Stream
{
readonly XXHash3 _hash = XXHash3.Create();
private readonly Stream _destination;
public HashingStream(Stream destination)
{
_destination = destination;
}
public Hash Hash { get; private set; }
public override void Write(byte[] buffer, int offset, int count)
{
_destination.Write(buffer, offset, count);
_hash.Update(new ReadOnlySpan<byte>(buffer, offset, count));
}
protected override void Dispose(bool disposing)
{
Hash = new Hash(_hash.Digest64());
base.Dispose(disposing);
} And that's why I would like to have public access to these methods. You have also ported the ZStd compression, which I use, too. Stream input = File.OpenRead(...);
var output = File.OpenWrite(...);
var compressing = new CompressingStream(output);
var hashing = new HashingStream(compressing);
using (hashing)
{
input.CopyTo(hashing);
}
var hash = hashing.Hash; If you would see such a stream in your repo, I'd be happy to propose a PR. Cheerio, |
This is a good request! I initially had the methods as public but got led astray while looking at how the .NET standard library implements hashing interfaces and forgot that this is a valid use-case. I will look into exposing those methods as public this or next week. |
No description provided.