1use crate::{
7 generated::models::{
8 PageBlobClientClearPagesOptions, PageBlobClientClearPagesResult,
9 PageBlobClientCreateOptions, PageBlobClientCreateResult,
10 PageBlobClientListPageRangesOptions, PageBlobClientResizeOptions,
11 PageBlobClientResizeResult, PageBlobClientSetSequenceNumberOptions,
12 PageBlobClientSetSequenceNumberResult, PageBlobClientUploadPagesFromUrlOptions,
13 PageBlobClientUploadPagesFromUrlResult, PageBlobClientUploadPagesOptions,
14 PageBlobClientUploadPagesResult, PageList, SequenceNumberActionType,
15 },
16 models::HttpRange,
17};
18use azure_core::{
19 base64,
20 error::CheckSuccessOptions,
21 fmt::SafeDebug,
22 http::{
23 pager::{PagerContinuation, PagerResult, PagerState},
24 ClientOptions, Method, NoFormat, PageIterator, Pipeline, PipelineSendOptions, RawResponse,
25 Request, RequestContent, Response, Url, UrlExt, XmlFormat,
26 },
27 time::to_rfc7231,
28 tracing, xml, Bytes, Result,
29};
30
31#[tracing::client]
32pub struct PageBlobClient {
33 pub(crate) endpoint: Url,
34 pub(crate) pipeline: Pipeline,
35 pub(crate) version: String,
36}
37
38#[derive(Clone, SafeDebug)]
40pub struct PageBlobClientOptions {
41 pub client_options: ClientOptions,
43 pub version: String,
45}
46
47impl PageBlobClient {
48 #[tracing::function("Storage.Blob.PageBlobClient.clearPages")]
88 pub async fn clear_pages(
89 &self,
90 range: HttpRange,
91 options: Option<PageBlobClientClearPagesOptions<'_>>,
92 ) -> Result<Response<PageBlobClientClearPagesResult, NoFormat>> {
93 let options = options.unwrap_or_default();
94 let ctx = options.method_options.context.to_borrowed();
95 let mut url = self.endpoint.clone();
96 let mut query_builder = url.query_builder();
97 query_builder.append_pair("comp", "page");
98 if let Some(timeout) = options.timeout {
99 query_builder.set_pair("timeout", timeout.to_string());
100 }
101 query_builder.build();
102 let mut request = Request::new(url, Method::Put);
103 request.insert_header("content-length", "0");
104 if let Some(if_match) = options.if_match.as_ref() {
105 request.insert_header("if-match", if_match.to_string());
106 }
107 if let Some(if_modified_since) = options.if_modified_since {
108 request.insert_header("if-modified-since", to_rfc7231(&if_modified_since));
109 }
110 if let Some(if_none_match) = options.if_none_match.as_ref() {
111 request.insert_header("if-none-match", if_none_match.to_string());
112 }
113 if let Some(if_unmodified_since) = options.if_unmodified_since {
114 request.insert_header("if-unmodified-since", to_rfc7231(&if_unmodified_since));
115 }
116 request.insert_header("range", range.to_string());
117 if let Some(encryption_algorithm) = options.encryption_algorithm.as_ref() {
118 request.insert_header(
119 "x-ms-encryption-algorithm",
120 encryption_algorithm.to_string(),
121 );
122 }
123 if let Some(encryption_key) = options.encryption_key.as_ref() {
124 request.insert_header("x-ms-encryption-key", encryption_key);
125 }
126 if let Some(encryption_key_sha256) = options.encryption_key_sha256.as_ref() {
127 request.insert_header("x-ms-encryption-key-sha256", encryption_key_sha256);
128 }
129 if let Some(encryption_scope) = options.encryption_scope.as_ref() {
130 request.insert_header("x-ms-encryption-scope", encryption_scope);
131 }
132 if let Some(if_sequence_number_equal_to) = options.if_sequence_number_equal_to {
133 request.insert_header(
134 "x-ms-if-sequence-number-eq",
135 if_sequence_number_equal_to.to_string(),
136 );
137 }
138 if let Some(if_sequence_number_less_than_or_equal_to) =
139 options.if_sequence_number_less_than_or_equal_to
140 {
141 request.insert_header(
142 "x-ms-if-sequence-number-le",
143 if_sequence_number_less_than_or_equal_to.to_string(),
144 );
145 }
146 if let Some(if_sequence_number_less_than) = options.if_sequence_number_less_than {
147 request.insert_header(
148 "x-ms-if-sequence-number-lt",
149 if_sequence_number_less_than.to_string(),
150 );
151 }
152 if let Some(if_tags) = options.if_tags.as_ref() {
153 request.insert_header("x-ms-if-tags", if_tags);
154 }
155 if let Some(lease_id) = options.lease_id.as_ref() {
156 request.insert_header("x-ms-lease-id", lease_id);
157 }
158 request.insert_header("x-ms-page-write", "clear");
159 request.insert_header("x-ms-version", &self.version);
160 let rsp = self
161 .pipeline
162 .send(
163 &ctx,
164 &mut request,
165 Some(PipelineSendOptions {
166 check_success: CheckSuccessOptions {
167 success_codes: &[201],
168 },
169 ..Default::default()
170 }),
171 )
172 .await?;
173 Ok(rsp.into())
174 }
175
176 #[tracing::function("Storage.Blob.PageBlobClient.create")]
218 pub async fn create(
219 &self,
220 size: u64,
221 options: Option<PageBlobClientCreateOptions<'_>>,
222 ) -> Result<Response<PageBlobClientCreateResult, NoFormat>> {
223 let options = options.unwrap_or_default();
224 let ctx = options.method_options.context.to_borrowed();
225 let mut url = self.endpoint.clone();
226 let mut query_builder = url.query_builder();
227 if let Some(timeout) = options.timeout {
228 query_builder.set_pair("timeout", timeout.to_string());
229 }
230 query_builder.build();
231 let mut request = Request::new(url, Method::Put);
232 request.insert_header("content-length", "0");
233 if let Some(if_match) = options.if_match.as_ref() {
234 request.insert_header("if-match", if_match.to_string());
235 }
236 if let Some(if_modified_since) = options.if_modified_since {
237 request.insert_header("if-modified-since", to_rfc7231(&if_modified_since));
238 }
239 if let Some(if_none_match) = options.if_none_match.as_ref() {
240 request.insert_header("if-none-match", if_none_match.to_string());
241 }
242 if let Some(if_unmodified_since) = options.if_unmodified_since {
243 request.insert_header("if-unmodified-since", to_rfc7231(&if_unmodified_since));
244 }
245 if let Some(tier) = options.tier.as_ref() {
246 request.insert_header("x-ms-access-tier", tier.to_string());
247 }
248 if let Some(blob_cache_control) = options.blob_cache_control.as_ref() {
249 request.insert_header("x-ms-blob-cache-control", blob_cache_control);
250 }
251 if let Some(blob_content_disposition) = options.blob_content_disposition.as_ref() {
252 request.insert_header("x-ms-blob-content-disposition", blob_content_disposition);
253 }
254 if let Some(blob_content_encoding) = options.blob_content_encoding.as_ref() {
255 request.insert_header("x-ms-blob-content-encoding", blob_content_encoding);
256 }
257 if let Some(blob_content_language) = options.blob_content_language.as_ref() {
258 request.insert_header("x-ms-blob-content-language", blob_content_language);
259 }
260 request.insert_header("x-ms-blob-content-length", size.to_string());
261 if let Some(blob_content_md5) = options.blob_content_md5 {
262 request.insert_header("x-ms-blob-content-md5", base64::encode(blob_content_md5));
263 }
264 if let Some(blob_content_type) = options.blob_content_type.as_ref() {
265 request.insert_header("x-ms-blob-content-type", blob_content_type);
266 }
267 if let Some(blob_sequence_number) = options.blob_sequence_number {
268 request.insert_header(
269 "x-ms-blob-sequence-number",
270 blob_sequence_number.to_string(),
271 );
272 }
273 request.insert_header("x-ms-blob-type", "PageBlob");
274 if let Some(encryption_algorithm) = options.encryption_algorithm.as_ref() {
275 request.insert_header(
276 "x-ms-encryption-algorithm",
277 encryption_algorithm.to_string(),
278 );
279 }
280 if let Some(encryption_key) = options.encryption_key.as_ref() {
281 request.insert_header("x-ms-encryption-key", encryption_key);
282 }
283 if let Some(encryption_key_sha256) = options.encryption_key_sha256.as_ref() {
284 request.insert_header("x-ms-encryption-key-sha256", encryption_key_sha256);
285 }
286 if let Some(encryption_scope) = options.encryption_scope.as_ref() {
287 request.insert_header("x-ms-encryption-scope", encryption_scope);
288 }
289 if let Some(if_tags) = options.if_tags.as_ref() {
290 request.insert_header("x-ms-if-tags", if_tags);
291 }
292 if let Some(immutability_policy_mode) = options.immutability_policy_mode.as_ref() {
293 request.insert_header(
294 "x-ms-immutability-policy-mode",
295 immutability_policy_mode.to_string(),
296 );
297 }
298 if let Some(immutability_policy_expiry) = options.immutability_policy_expiry {
299 request.insert_header(
300 "x-ms-immutability-policy-until-date",
301 to_rfc7231(&immutability_policy_expiry),
302 );
303 }
304 if let Some(lease_id) = options.lease_id.as_ref() {
305 request.insert_header("x-ms-lease-id", lease_id);
306 }
307 if let Some(legal_hold) = options.legal_hold {
308 request.insert_header("x-ms-legal-hold", legal_hold.to_string());
309 }
310 if let Some(metadata) = options.metadata.as_ref() {
311 for (k, v) in metadata {
312 request.insert_header(format!("x-ms-meta-{k}"), v);
313 }
314 }
315 if let Some(blob_tags_string) = options.blob_tags_string.as_ref() {
316 request.insert_header("x-ms-tags", blob_tags_string);
317 }
318 request.insert_header("x-ms-version", &self.version);
319 let rsp = self
320 .pipeline
321 .send(
322 &ctx,
323 &mut request,
324 Some(PipelineSendOptions {
325 check_success: CheckSuccessOptions {
326 success_codes: &[201],
327 },
328 ..Default::default()
329 }),
330 )
331 .await?;
332 Ok(rsp.into())
333 }
334
335 #[tracing::function("Storage.Blob.PageBlobClient.getPageRanges")]
372 pub fn list_page_ranges(
373 &self,
374 options: Option<PageBlobClientListPageRangesOptions<'_>>,
375 ) -> Result<PageIterator<Response<PageList, XmlFormat>>> {
376 let options = options.unwrap_or_default().into_owned();
377 let pipeline = self.pipeline.clone();
378 let mut first_url = self.endpoint.clone();
379 let mut query_builder = first_url.query_builder();
380 query_builder.append_pair("comp", "pagelist");
381 if let Some(marker) = options.marker.as_ref() {
382 query_builder.set_pair("marker", marker);
383 }
384 if let Some(maxresults) = options.maxresults {
385 query_builder.set_pair("maxresults", maxresults.to_string());
386 }
387 if let Some(snapshot) = options.snapshot.as_ref() {
388 query_builder.set_pair("snapshot", snapshot);
389 }
390 if let Some(timeout) = options.timeout {
391 query_builder.set_pair("timeout", timeout.to_string());
392 }
393 query_builder.build();
394 #[derive(serde::Deserialize)]
395 struct PageBlobClientListPageRangesPage {
396 #[serde(rename = "NextMarker")]
397 next_marker: Option<String>,
398 }
399
400 let version = self.version.clone();
401 Ok(PageIterator::new(
402 move |marker: PagerState, pager_options| {
403 let mut url = first_url.clone();
404 if let PagerState::More(marker) = marker {
405 let mut query_builder = url.query_builder();
406 query_builder.set_pair("marker", marker.as_ref());
407 query_builder.build();
408 }
409 let mut request = Request::new(url, Method::Get);
410 request.insert_header("accept", "application/xml");
411 if let Some(if_match) = options.if_match.as_ref() {
412 request.insert_header("if-match", if_match.to_string());
413 }
414 if let Some(if_modified_since) = options.if_modified_since {
415 request.insert_header("if-modified-since", to_rfc7231(&if_modified_since));
416 }
417 if let Some(if_none_match) = options.if_none_match.as_ref() {
418 request.insert_header("if-none-match", if_none_match.to_string());
419 }
420 if let Some(if_unmodified_since) = options.if_unmodified_since {
421 request.insert_header("if-unmodified-since", to_rfc7231(&if_unmodified_since));
422 }
423 if let Some(range) = options.range.as_ref() {
424 request.insert_header("range", range.to_string());
425 }
426 if let Some(if_tags) = options.if_tags.as_ref() {
427 request.insert_header("x-ms-if-tags", if_tags);
428 }
429 if let Some(lease_id) = options.lease_id.as_ref() {
430 request.insert_header("x-ms-lease-id", lease_id);
431 }
432 request.insert_header("x-ms-version", &version);
433 let pipeline = pipeline.clone();
434 Box::pin(async move {
435 let rsp = pipeline
436 .send(
437 &pager_options.context,
438 &mut request,
439 Some(PipelineSendOptions {
440 check_success: CheckSuccessOptions {
441 success_codes: &[200],
442 },
443 ..Default::default()
444 }),
445 )
446 .await?;
447 let (status, headers, body) = rsp.deconstruct();
448 let res: PageBlobClientListPageRangesPage = xml::from_xml(&body)?;
449 let rsp = RawResponse::from_bytes(status, headers, body).into();
450 Ok(match res.next_marker {
451 Some(next_marker) if !next_marker.is_empty() => PagerResult::More {
452 response: rsp,
453 continuation: PagerContinuation::Token(next_marker),
454 },
455 _ => PagerResult::Done { response: rsp },
456 })
457 })
458 },
459 Some(options.method_options),
460 ))
461 }
462
463 #[tracing::function("Storage.Blob.PageBlobClient.resize")]
501 pub async fn resize(
502 &self,
503 size: u64,
504 options: Option<PageBlobClientResizeOptions<'_>>,
505 ) -> Result<Response<PageBlobClientResizeResult, NoFormat>> {
506 let options = options.unwrap_or_default();
507 let ctx = options.method_options.context.to_borrowed();
508 let mut url = self.endpoint.clone();
509 let mut query_builder = url.query_builder();
510 query_builder.append_pair("comp", "properties");
511 if let Some(timeout) = options.timeout {
512 query_builder.set_pair("timeout", timeout.to_string());
513 }
514 query_builder.build();
515 let mut request = Request::new(url, Method::Put);
516 if let Some(if_match) = options.if_match.as_ref() {
517 request.insert_header("if-match", if_match.to_string());
518 }
519 if let Some(if_modified_since) = options.if_modified_since {
520 request.insert_header("if-modified-since", to_rfc7231(&if_modified_since));
521 }
522 if let Some(if_none_match) = options.if_none_match.as_ref() {
523 request.insert_header("if-none-match", if_none_match.to_string());
524 }
525 if let Some(if_unmodified_since) = options.if_unmodified_since {
526 request.insert_header("if-unmodified-since", to_rfc7231(&if_unmodified_since));
527 }
528 request.insert_header("x-ms-blob-content-length", size.to_string());
529 if let Some(encryption_algorithm) = options.encryption_algorithm.as_ref() {
530 request.insert_header(
531 "x-ms-encryption-algorithm",
532 encryption_algorithm.to_string(),
533 );
534 }
535 if let Some(encryption_key) = options.encryption_key.as_ref() {
536 request.insert_header("x-ms-encryption-key", encryption_key);
537 }
538 if let Some(encryption_key_sha256) = options.encryption_key_sha256.as_ref() {
539 request.insert_header("x-ms-encryption-key-sha256", encryption_key_sha256);
540 }
541 if let Some(encryption_scope) = options.encryption_scope.as_ref() {
542 request.insert_header("x-ms-encryption-scope", encryption_scope);
543 }
544 if let Some(if_tags) = options.if_tags.as_ref() {
545 request.insert_header("x-ms-if-tags", if_tags);
546 }
547 if let Some(lease_id) = options.lease_id.as_ref() {
548 request.insert_header("x-ms-lease-id", lease_id);
549 }
550 request.insert_header("x-ms-version", &self.version);
551 let rsp = self
552 .pipeline
553 .send(
554 &ctx,
555 &mut request,
556 Some(PipelineSendOptions {
557 check_success: CheckSuccessOptions {
558 success_codes: &[200],
559 },
560 ..Default::default()
561 }),
562 )
563 .await?;
564 Ok(rsp.into())
565 }
566
567 #[tracing::function("Storage.Blob.PageBlobClient.setSequenceNumber")]
607 pub async fn set_sequence_number(
608 &self,
609 sequence_number_action: SequenceNumberActionType,
610 options: Option<PageBlobClientSetSequenceNumberOptions<'_>>,
611 ) -> Result<Response<PageBlobClientSetSequenceNumberResult, NoFormat>> {
612 let options = options.unwrap_or_default();
613 let ctx = options.method_options.context.to_borrowed();
614 let mut url = self.endpoint.clone();
615 let mut query_builder = url.query_builder();
616 query_builder.append_pair("comp", "properties");
617 if let Some(timeout) = options.timeout {
618 query_builder.set_pair("timeout", timeout.to_string());
619 }
620 query_builder.build();
621 let mut request = Request::new(url, Method::Put);
622 if let Some(if_match) = options.if_match.as_ref() {
623 request.insert_header("if-match", if_match.to_string());
624 }
625 if let Some(if_modified_since) = options.if_modified_since {
626 request.insert_header("if-modified-since", to_rfc7231(&if_modified_since));
627 }
628 if let Some(if_none_match) = options.if_none_match.as_ref() {
629 request.insert_header("if-none-match", if_none_match.to_string());
630 }
631 if let Some(if_unmodified_since) = options.if_unmodified_since {
632 request.insert_header("if-unmodified-since", to_rfc7231(&if_unmodified_since));
633 }
634 if let Some(blob_sequence_number) = options.blob_sequence_number {
635 request.insert_header(
636 "x-ms-blob-sequence-number",
637 blob_sequence_number.to_string(),
638 );
639 }
640 if let Some(if_tags) = options.if_tags.as_ref() {
641 request.insert_header("x-ms-if-tags", if_tags);
642 }
643 if let Some(lease_id) = options.lease_id.as_ref() {
644 request.insert_header("x-ms-lease-id", lease_id);
645 }
646 request.insert_header(
647 "x-ms-sequence-number-action",
648 sequence_number_action.to_string(),
649 );
650 request.insert_header("x-ms-version", &self.version);
651 let rsp = self
652 .pipeline
653 .send(
654 &ctx,
655 &mut request,
656 Some(PipelineSendOptions {
657 check_success: CheckSuccessOptions {
658 success_codes: &[200],
659 },
660 ..Default::default()
661 }),
662 )
663 .await?;
664 Ok(rsp.into())
665 }
666
667 #[tracing::function("Storage.Blob.PageBlobClient.uploadPages")]
712 pub async fn upload_pages(
713 &self,
714 body: RequestContent<Bytes, NoFormat>,
715 content_length: u64,
716 range: HttpRange,
717 options: Option<PageBlobClientUploadPagesOptions<'_>>,
718 ) -> Result<Response<PageBlobClientUploadPagesResult, NoFormat>> {
719 let options = options.unwrap_or_default();
720 let ctx = options.method_options.context.to_borrowed();
721 let mut url = self.endpoint.clone();
722 let mut query_builder = url.query_builder();
723 query_builder.append_pair("comp", "page");
724 if let Some(timeout) = options.timeout {
725 query_builder.set_pair("timeout", timeout.to_string());
726 }
727 query_builder.build();
728 let mut request = Request::new(url, Method::Put);
729 request.insert_header("content-length", content_length.to_string());
730 if let Some(transactional_content_md5) = options.transactional_content_md5 {
731 request.insert_header("content-md5", base64::encode(transactional_content_md5));
732 }
733 request.insert_header("content-type", "application/octet-stream");
734 if let Some(if_match) = options.if_match.as_ref() {
735 request.insert_header("if-match", if_match.to_string());
736 }
737 if let Some(if_modified_since) = options.if_modified_since {
738 request.insert_header("if-modified-since", to_rfc7231(&if_modified_since));
739 }
740 if let Some(if_none_match) = options.if_none_match.as_ref() {
741 request.insert_header("if-none-match", if_none_match.to_string());
742 }
743 if let Some(if_unmodified_since) = options.if_unmodified_since {
744 request.insert_header("if-unmodified-since", to_rfc7231(&if_unmodified_since));
745 }
746 request.insert_header("range", range.to_string());
747 if let Some(transactional_content_crc64) = options.transactional_content_crc64 {
748 request.insert_header(
749 "x-ms-content-crc64",
750 base64::encode(transactional_content_crc64),
751 );
752 }
753 if let Some(encryption_algorithm) = options.encryption_algorithm.as_ref() {
754 request.insert_header(
755 "x-ms-encryption-algorithm",
756 encryption_algorithm.to_string(),
757 );
758 }
759 if let Some(encryption_key) = options.encryption_key.as_ref() {
760 request.insert_header("x-ms-encryption-key", encryption_key);
761 }
762 if let Some(encryption_key_sha256) = options.encryption_key_sha256.as_ref() {
763 request.insert_header("x-ms-encryption-key-sha256", encryption_key_sha256);
764 }
765 if let Some(encryption_scope) = options.encryption_scope.as_ref() {
766 request.insert_header("x-ms-encryption-scope", encryption_scope);
767 }
768 if let Some(if_sequence_number_equal_to) = options.if_sequence_number_equal_to {
769 request.insert_header(
770 "x-ms-if-sequence-number-eq",
771 if_sequence_number_equal_to.to_string(),
772 );
773 }
774 if let Some(if_sequence_number_less_than_or_equal_to) =
775 options.if_sequence_number_less_than_or_equal_to
776 {
777 request.insert_header(
778 "x-ms-if-sequence-number-le",
779 if_sequence_number_less_than_or_equal_to.to_string(),
780 );
781 }
782 if let Some(if_sequence_number_less_than) = options.if_sequence_number_less_than {
783 request.insert_header(
784 "x-ms-if-sequence-number-lt",
785 if_sequence_number_less_than.to_string(),
786 );
787 }
788 if let Some(if_tags) = options.if_tags.as_ref() {
789 request.insert_header("x-ms-if-tags", if_tags);
790 }
791 if let Some(lease_id) = options.lease_id.as_ref() {
792 request.insert_header("x-ms-lease-id", lease_id);
793 }
794 request.insert_header("x-ms-page-write", "update");
795 request.insert_header("x-ms-version", &self.version);
796 request.set_body(body);
797 let rsp = self
798 .pipeline
799 .send(
800 &ctx,
801 &mut request,
802 Some(PipelineSendOptions {
803 check_success: CheckSuccessOptions {
804 success_codes: &[201],
805 },
806 ..Default::default()
807 }),
808 )
809 .await?;
810 Ok(rsp.into())
811 }
812
813 #[tracing::function("Storage.Blob.PageBlobClient.uploadPagesFromUrl")]
859 pub async fn upload_pages_from_url(
860 &self,
861 source_url: String,
862 source_range: HttpRange,
863 content_length: u64,
864 range: HttpRange,
865 options: Option<PageBlobClientUploadPagesFromUrlOptions<'_>>,
866 ) -> Result<Response<PageBlobClientUploadPagesFromUrlResult, NoFormat>> {
867 let options = options.unwrap_or_default();
868 let ctx = options.method_options.context.to_borrowed();
869 let mut url = self.endpoint.clone();
870 let mut query_builder = url.query_builder();
871 query_builder.append_pair("comp", "page");
872 if let Some(timeout) = options.timeout {
873 query_builder.set_pair("timeout", timeout.to_string());
874 }
875 query_builder.build();
876 let mut request = Request::new(url, Method::Put);
877 request.insert_header("content-length", content_length.to_string());
878 if let Some(if_match) = options.if_match.as_ref() {
879 request.insert_header("if-match", if_match.to_string());
880 }
881 if let Some(if_modified_since) = options.if_modified_since {
882 request.insert_header("if-modified-since", to_rfc7231(&if_modified_since));
883 }
884 if let Some(if_none_match) = options.if_none_match.as_ref() {
885 request.insert_header("if-none-match", if_none_match.to_string());
886 }
887 if let Some(if_unmodified_since) = options.if_unmodified_since {
888 request.insert_header("if-unmodified-since", to_rfc7231(&if_unmodified_since));
889 }
890 request.insert_header("range", range.to_string());
891 request.insert_header("x-ms-copy-source", source_url);
892 if let Some(copy_source_authorization) = options.copy_source_authorization.as_ref() {
893 request.insert_header("x-ms-copy-source-authorization", copy_source_authorization);
894 }
895 if let Some(encryption_algorithm) = options.encryption_algorithm.as_ref() {
896 request.insert_header(
897 "x-ms-encryption-algorithm",
898 encryption_algorithm.to_string(),
899 );
900 }
901 if let Some(encryption_key) = options.encryption_key.as_ref() {
902 request.insert_header("x-ms-encryption-key", encryption_key);
903 }
904 if let Some(encryption_key_sha256) = options.encryption_key_sha256.as_ref() {
905 request.insert_header("x-ms-encryption-key-sha256", encryption_key_sha256);
906 }
907 if let Some(encryption_scope) = options.encryption_scope.as_ref() {
908 request.insert_header("x-ms-encryption-scope", encryption_scope);
909 }
910 if let Some(file_request_intent) = options.file_request_intent.as_ref() {
911 request.insert_header("x-ms-file-request-intent", file_request_intent.to_string());
912 }
913 if let Some(if_sequence_number_equal_to) = options.if_sequence_number_equal_to {
914 request.insert_header(
915 "x-ms-if-sequence-number-eq",
916 if_sequence_number_equal_to.to_string(),
917 );
918 }
919 if let Some(if_sequence_number_less_than_or_equal_to) =
920 options.if_sequence_number_less_than_or_equal_to
921 {
922 request.insert_header(
923 "x-ms-if-sequence-number-le",
924 if_sequence_number_less_than_or_equal_to.to_string(),
925 );
926 }
927 if let Some(if_sequence_number_less_than) = options.if_sequence_number_less_than {
928 request.insert_header(
929 "x-ms-if-sequence-number-lt",
930 if_sequence_number_less_than.to_string(),
931 );
932 }
933 if let Some(if_tags) = options.if_tags.as_ref() {
934 request.insert_header("x-ms-if-tags", if_tags);
935 }
936 if let Some(lease_id) = options.lease_id.as_ref() {
937 request.insert_header("x-ms-lease-id", lease_id);
938 }
939 request.insert_header("x-ms-page-write", "update");
940 if let Some(source_content_crc64) = options.source_content_crc64 {
941 request.insert_header(
942 "x-ms-source-content-crc64",
943 base64::encode(source_content_crc64),
944 );
945 }
946 if let Some(source_content_md5) = options.source_content_md5 {
947 request.insert_header(
948 "x-ms-source-content-md5",
949 base64::encode(source_content_md5),
950 );
951 }
952 if let Some(source_encryption_algorithm) = options.source_encryption_algorithm.as_ref() {
953 request.insert_header(
954 "x-ms-source-encryption-algorithm",
955 source_encryption_algorithm.to_string(),
956 );
957 }
958 if let Some(source_encryption_key) = options.source_encryption_key.as_ref() {
959 request.insert_header("x-ms-source-encryption-key", source_encryption_key);
960 }
961 if let Some(source_encryption_key_sha256) = options.source_encryption_key_sha256.as_ref() {
962 request.insert_header(
963 "x-ms-source-encryption-key-sha256",
964 source_encryption_key_sha256,
965 );
966 }
967 if let Some(source_if_match) = options.source_if_match.as_ref() {
968 request.insert_header("x-ms-source-if-match", source_if_match.to_string());
969 }
970 if let Some(source_if_modified_since) = options.source_if_modified_since {
971 request.insert_header(
972 "x-ms-source-if-modified-since",
973 to_rfc7231(&source_if_modified_since),
974 );
975 }
976 if let Some(source_if_none_match) = options.source_if_none_match.as_ref() {
977 request.insert_header(
978 "x-ms-source-if-none-match",
979 source_if_none_match.to_string(),
980 );
981 }
982 if let Some(source_if_unmodified_since) = options.source_if_unmodified_since {
983 request.insert_header(
984 "x-ms-source-if-unmodified-since",
985 to_rfc7231(&source_if_unmodified_since),
986 );
987 }
988 request.insert_header("x-ms-source-range", source_range.to_string());
989 request.insert_header("x-ms-version", &self.version);
990 let rsp = self
991 .pipeline
992 .send(
993 &ctx,
994 &mut request,
995 Some(PipelineSendOptions {
996 check_success: CheckSuccessOptions {
997 success_codes: &[201],
998 },
999 ..Default::default()
1000 }),
1001 )
1002 .await?;
1003 Ok(rsp.into())
1004 }
1005}
1006
1007pub(crate) const DEFAULT_VERSION: &str = "2026-04-06";
1009
1010impl Default for PageBlobClientOptions {
1011 fn default() -> Self {
1012 Self {
1013 client_options: ClientOptions::default(),
1014 version: String::from(DEFAULT_VERSION),
1015 }
1016 }
1017}