azure_storage_blobs/options/
blob_content_md5.rs

1use azure_core::{
2    base64,
3    headers::{self, Header},
4};
5use azure_storage::ConsistencyMD5;
6
7#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord)]
8pub struct BlobContentMD5(pub [u8; 16]);
9
10#[cfg(feature = "md5")]
11impl From<md5::Digest> for BlobContentMD5 {
12    fn from(md5: md5::Digest) -> Self {
13        BlobContentMD5(md5.0)
14    }
15}
16
17impl From<[u8; 16]> for BlobContentMD5 {
18    fn from(md5: [u8; 16]) -> Self {
19        BlobContentMD5(md5)
20    }
21}
22
23impl From<ConsistencyMD5> for BlobContentMD5 {
24    fn from(md5: ConsistencyMD5) -> Self {
25        BlobContentMD5(*md5.as_slice())
26    }
27}
28
29impl Header for BlobContentMD5 {
30    fn name(&self) -> headers::HeaderName {
31        "x-ms-blob-content-md5".into()
32    }
33
34    fn value(&self) -> headers::HeaderValue {
35        base64::encode(self.0).into()
36    }
37}