Is there a straightforward way to read all bytes f...
# io
r
Is there a straightforward way to read all bytes from a source in some reasonable chunks, ideally in a way that can handle the consumer suspending? My particular need is to send it to
MessageDigest
but it seems like a pretty straightforward and common operation
So far the best way seems to be to essentially re-implement
OutputStreamSink
j
Isn't MessageDigest blocking? Who is suspending?
Generally you'll want to use UnsafeBufferOperations to pass the backing byte arrays to MessageDigest directly and without copies.
r
Nobody is suspending at the moment, I'm just thinking ahead. > Generally you'll want to use UnsafeBufferOperations to pass the backing byte arrays to MessageDigest directly and without copies. That's what I'm doing, I'm just surprised that I needed to write it myself instead of there being a
consume
function or similar and was wondering if I had just missed it