http_content_digest/
digest.rs

1mod body;
2mod header;
3mod request;
4mod response;
5
6pub use self::body::*;
7
8use crate::base64::Base64EncodedString;
9
10#[derive(Debug, Clone, Eq, PartialEq, Hash)]
11pub struct DigestHash(Vec<u8>);
12
13impl DigestHash {
14    pub fn new(digest: Vec<u8>) -> Self {
15        Self(digest)
16    }
17
18    pub fn to_base64(&self) -> Base64EncodedString {
19        Base64EncodedString::new(&self.0)
20    }
21}
22
23pub trait ContentHasher: 'static + Send + Sync {
24    const DIGEST_ALG: &'static str;
25
26    fn hash(content: &[u8]) -> DigestHash;
27}
28
29pub trait ContentDigest {
30    type Error;
31    type Content;
32    fn digest<H: ContentHasher>(
33        self,
34    ) -> impl Future<Output = Result<Self::Content, Self::Error>> + Send
35    where
36        Self: Sized;
37    fn verify_digest<H: ContentHasher>(
38        self,
39    ) -> impl Future<Output = Result<Self::Content, Self::Error>> + Send
40    where
41        Self: Sized;
42}