azure_storage_blobs/options/
block_id.rs
1use azure_core::{base64, AppendToUrlQuery, Url};
2use bytes::Bytes;
3
4#[derive(Debug, Clone, PartialEq, Eq)]
10pub struct BlockId(Bytes);
11
12impl BlockId {
13 pub fn new(block_id: impl Into<Bytes>) -> Self {
16 Self(block_id.into())
17 }
18
19 pub fn bytes(&self) -> Bytes {
22 self.0.clone()
23 }
24}
25
26impl AppendToUrlQuery for BlockId {
27 fn append_to_url_query(&self, url: &mut Url) {
28 url.query_pairs_mut()
29 .append_pair("blockid", &base64::encode(&self.0));
30 }
31}
32
33impl<B> From<B> for BlockId
34where
35 B: Into<Bytes>,
36{
37 fn from(v: B) -> Self {
38 Self::new(v)
39 }
40}
41
42impl AsRef<[u8]> for BlockId {
43 fn as_ref(&self) -> &[u8] {
44 self.0.as_ref()
45 }
46}