traits
traits copied to clipboard
digest: add a `Read`and `Write` wrappers
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.
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.