traits icon indicating copy to clipboard operation
traits copied to clipboard

digest: add a `Read`and `Write` wrappers

Open piegamesde opened this issue 4 years ago • 1 comments

I can pass a hasher where I need a Write, and I'll get the digest of the written bytes. I can also have a reader and std::io::copy into the hasher to get the digest of all read bytes. In both cases, those bytes go into the void, there is nothing of them left except for the hash.

Sometimes, I want to process data and hash it along the way. So it'd be cool to have Read and Write wrappers for hashers that can decorate around any IO and give me the hash while passing the data along.

piegamesde avatar May 07 '21 13:05 piegamesde

I've found https://stackoverflow.com/questions/60336419/how-can-i-pipe-bytes-from-a-reader-to-a-writer-with-an-interceptor which has more or less the same problem. The workaround answer suggests to use a Write fanout like provided by the broadcast crate.

Nevertheless, a direct solution to the problem would be appreciated. I'd be willing to help implement, given some guidance on how an acceptable solution would look like.

piegamesde avatar Aug 01 '21 11:08 piegamesde