I want to write a bunch of things to a file and then write the digest of everything I've written. I thought it might be nice to have an API like so:
let mut file = File::open("foo.txt")?;
let mut digest = Sha1::new();
let mut out = WithDigest::new(&mut file, &mut digest);
for thingy in things_to_write {
out.write_all(&thingy)?;
}
let mut digest_bytes = Vec::with_capacity(digest.output_bytes());
digest.result(&mut digest_bytes);
file.write_all(&digest_bytes)?;
file.flush()?
I wrote a rough untested draft of how this could be implemented. What would you think of a PR?
I want to write a bunch of things to a file and then write the digest of everything I've written. I thought it might be nice to have an API like so:
I wrote a rough untested draft of how this could be implemented. What would you think of a PR?