[Storage] Finalized managed_download and managed_download_to drop-in replacements#4068
Conversation
There was a problem hiding this comment.
Pull request overview
This PR promotes the managed, partitioned (multi-part) download implementation to be the default download() API on BlobClient and adds a new BlockBlobClient::download() that returns a hand-written download result type containing both the body stream and extracted response headers/metadata.
Changes:
- Replaced the old single-shot
BlobClient::download()(returningAsyncResponse<...>) with a managed download that returns a newBlobClientDownloadResultdirectly (alias ofBlockBlobClientDownloadResult). - Updated partitioned download internals to return
(RawResponse, PinnedStream)so callers can surface headers while streaming the body. - Updated tests and examples to use the new result type shape (
.body,.raw_response, and direct header fields).
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/storage/azure_storage_blob/src/clients/block_blob_client.rs | Adds BlockBlobClient::download() managed download implementation, behavior adapter, and header extraction into the new result type. |
| sdk/storage/azure_storage_blob/src/clients/blob_client.rs | Switches BlobClient::download() to delegate to BlockBlobClient::download() and removes the old managed download implementation from BlobClient. |
| sdk/storage/azure_storage_blob/src/partitioned_transfer/download.rs | Changes partitioned download to return (RawResponse, PinnedStream) and adjusts tests accordingly. |
| sdk/storage/azure_storage_blob/src/models/download_result.rs | Introduces BlockBlobClientDownloadResult holding stream + extracted headers/metadata + RawResponse. |
| sdk/storage/azure_storage_blob/src/models/mod.rs | Wires in the new download_result module and re-exports new result/options aliases. |
| sdk/storage/azure_storage_blob/src/models/method_options.rs | Renames BlobClientManagedDownloadOptions to BlockBlobClientDownloadOptions and updates docs. |
| sdk/storage/azure_storage_blob/tests/streaming.rs | Updates streaming tests to consume the new download result (.body, .raw_response). |
| sdk/storage/azure_storage_blob/tests/page_blob_client.rs | Updates page blob tests to the new download return type. |
| sdk/storage/azure_storage_blob/tests/block_blob_client.rs | Updates block blob tests to the new download return type. |
| sdk/storage/azure_storage_blob/tests/blob_cpk.rs | Updates CPK-related download usages to the new return type. |
| sdk/storage/azure_storage_blob/tests/blob_client.rs | Updates blob client integration tests (incl. managed download tests) to the new API surface. |
| sdk/storage/azure_storage_blob/tests/blob_client_versioning.rs | Updates versioning tests to use the new download result. |
| sdk/storage/azure_storage_blob/tests/blob_client_snapshot.rs | Updates snapshot tests to use the new download result. |
| sdk/storage/azure_storage_blob/tests/blob_client_options.rs | Updates options tests to use the new download result. |
| sdk/storage/azure_storage_blob/tests/append_blob_client.rs | Updates append blob tests to use the new download result. |
| sdk/storage/azure_storage_blob/examples/blob_storage_logging.rs | Updates example to collect from response.body directly. |
| sdk/storage/azure_storage_blob/CHANGELOG.md | Documents the download API breaking changes for the crate. |
| sdk/core/typespec_client_core/src/http/response.rs | Makes AsyncResponseBody::new public to allow constructing bodies from PinnedStream across crates. |
| sdk/core/typespec_client_core/src/http/mod.rs | Re-exports AsyncResponseBody from the http module. |
| sdk/core/azure_core/src/http/mod.rs | Re-exports AsyncResponseBody from azure_core::http. |
sdk/storage/azure_storage_blob/src/clients/block_blob_client.rs
Outdated
Show resolved
Hide resolved
sdk/storage/azure_storage_blob/src/clients/block_blob_client.rs
Outdated
Show resolved
Hide resolved
sdk/storage/azure_storage_blob/src/partitioned_transfer/download.rs
Outdated
Show resolved
Hide resolved
sdk/storage/azure_storage_blob/src/clients/block_blob_client.rs
Outdated
Show resolved
Hide resolved
sdk/storage/azure_storage_blob/src/clients/block_blob_client.rs
Outdated
Show resolved
Hide resolved
heaths
left a comment
There was a problem hiding this comment.
AsyncResponse should not be publicly creatable. We can explore other options.
download APImanaged_download and managed_download_to drop-in replacements
heaths
left a comment
There was a problem hiding this comment.
Changes to sdk/core approved. Good catch. I'm surprised our linter didn't complain since it's in a public API but, then again, types you return don't technically have to: this happens in a couple places I've seen in tokio.
Replaces
BlobClient::download()withmanaged_downloadand the same exercise fordownload_into.Summary
Promotes the managed (multi-part) download implementation to be the sole
download()API onBlobClient, and addsdownload_into()which writes directly into a caller-supplied buffer. Both APIs use parallel range requests under the hood and return structured result types with all service headers parsed out directly.Breaking Changes
BlobClient::download()return type changedResult<AsyncResponse<BlobClientDownloadResult>>Result<BlobClientDownloadResult>- all headers are fields on the result struct directly; no.awaiton the response wrapper neededBlobClientDownloadResultis a new hand-written struct with abody: AsyncResponseBodyfield plus aproperties: BlobDownloadPropertiesfield covering every header the Blob service returns (ETag, Content-Type, lease state, copy status, blob type, metadata, object-replication rules, etc.)BlobClientDownloadResultHeaderstrait removed — superseded by direct field access onBlobClientDownloadResultrangefield type onBlobClientDownloadOptionschangedOption<String>Option<Range<usize>>BlobClientManagedDownloadOptionsrenamed toBlobClientDownloadOptionsBlockBlobClient::download()andBlockBlobClientDownloadBehaviorremoved - download belongs onBlobClientChanges
sdk/storage/azure_storage_blobsrc/clients/blob_client.rsBlobClient::download()now owns the full managed (multi-part) download implementation viaBlobClientDownloadBehaviorand theDEFAULT_DOWNLOAD_PARALLEL/DEFAULT_DOWNLOAD_PARTITION_SIZEconstantsBlobClient::download_into()added - writes blob content directly into a caller-provided&mut [u8]buffer using the same partitioned transfer enginesrc/clients/block_blob_client.rsBlockBlobClient::download(),BlockBlobClientDownloadBehavior, and all download-related importssrc/models/download_result.rs(new file)BlobClientDownloadResultwithbody,properties, andheadersfieldsBlobDownloadPropertiescovers every header returned by the Blob serviceBlobClientDownloadResult::from_headers(AsyncRawResponse)handles all header parsing in one placesrc/models/method_options.rsBlobClientManagedDownloadOptions-->BlobClientDownloadOptionssrc/models/mod.rsBlobClientDownloadResult,BlobDownloadProperties, andBlobClientDownloadOptionssrc/parsers.rspub(crate) fn parse_metadata_and_replication_headers(headers)- extractsx-ms-meta-*andx-ms-or-*headers into reusable mapssrc/partitioned_transfer/download.rsdownload()changed toAzureResult<AsyncRawResponse>- surfaces the initial range-response headers without wrapping them in a misleading empty-bodyRawResponseTests
Updated the following integration test files to use direct field access on
BlobClientDownloadResult:tests/blob_client.rstests/blob_client_options.rstests/blob_client_snapshot.rstests/blob_client_versioning.rstests/blob_cpk.rstests/block_blob_client.rstests/append_blob_client.rstests/page_blob_client.rstests/streaming.rs