add adapters for digest trait#678
Conversation
| ] | ||
|
|
||
| [features] | ||
| default = ["digest"] |
There was a problem hiding this comment.
should be fine to enable by default since digest is also no_std without the default features
There was a problem hiding this comment.
i'd prefer to make it optional to not bloat up people's dependency trees and also because the 0.10 vs 0.11 thing
| fn update(&mut self, data: &[u8]) { | ||
| match self.inner.write_all(data) { | ||
| Ok(()) => {} | ||
| Err(_) => unreachable!(), |
There was a problem hiding this comment.
it's better to do Err(e) => match e{} so the compiler checks for you that it's actually unreachable.
|
Interesting timing, we were discussing it yesterday in Matrix https://matrix.to/#/!BHcierreUuwCMxVqOf:matrix.org/$e8f4Ojv7DjdxQcGhRarquhTGY88GPgchLVjG93ZPjxE?via=matrix.org&via=catircservices.org&via=mozilla.org IMO it's a bit niche. For example, the Also the rust-crypto ecosystem isn't known for its stability. Latest |
|
thanks for taking a look. i find these traits far superior to those in long story short, i am currently working on a JSON Web Token library, which often needs to write data after encoding it & authenticating it. it ends up being intuitive to chain APIs that implement e.g. writing HS256 signed data encoded as base64url becomes incredibly simple (can be done directly to a TCP stream) output: as for the digest crate not providing an adapter, i think there are 2 reasons:
|
there is an existing trait digest::Update used in very popular crates like sha2
this trait is essentially equivalent to
ErrorType<Error=Infallible> + Writethis PR adds new adapters between the two traits with an optional dependency on digest
example usage: