RustCrypto/traits

digest: reduce the number of required methods in `Digest`?

Closed this issue · 2 comments

It seems that a number of currently required methods in Digest can be expressed via other methods, for example:

  • chain_update via update
  • finalize via finalize_into
  • finalize_reset via reset and finalize
  • finalize_into_reset via reset and finalize_into
  • possibly, new via new_with_prefix with an empty slice

Is there a reason it's not currently done?

You mean why those methods don't have blanket impls? It's because those implementations reside in the blanket impl of the trait itself. It uses the underlying traits directly without adding a layer of indirection (i.e. we use Update::update directly instead of using Digest::update which in turn uses Update::update). We could've used blanket methods implementations, but it's a very minor implementation detail considering that Digest should not be directly implemented by user crates.

Ah, I see, that makes sense. I don't think it would hurt adding the blanket impls still, but I don't insist on it. Closing.