Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Commit

Permalink
Storage blob - functions must not require cloneable Client if no stre…
Browse files Browse the repository at this point in the history
…am function is called (#316)

* relaxed list_blobs requirements if not calling `stream`
  • Loading branch information
Francesco Cogno authored Jul 19, 2020
1 parent 5c90b4a commit ff2d844
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
2 changes: 1 addition & 1 deletion azure_sdk_storage_blob/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "azure_sdk_storage_blob"
version = "0.45.1"
version = "0.45.2"
description = "Rust wrappers around Microsoft Azure REST APIs - Blob storage crate"
readme = "README.md"
authors = ["Francesco Cogno <[email protected]>", "Max Gortman <[email protected]>", "Dong Liu <[email protected]>"]
Expand Down
28 changes: 28 additions & 0 deletions azure_sdk_storage_blob/examples/blob_03_boxed_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,34 @@ async fn main() -> Result<(), Box<dyn Error>> {
Ok(())
}

async fn list_blobs_box<'a>(
client: &'a Box<dyn Client>,
container: &'a str,
) -> Result<(), AzureError> {
client
.list_blobs()
.with_max_results(100)
.with_container_name(container)
.finalize()
.await?;

Ok(())
}

async fn list_blobs_arc<'a>(
client: &'a Arc<dyn Client>,
container: &'a str,
) -> Result<(), AzureError> {
client
.list_blobs()
.with_max_results(100)
.with_container_name(container)
.finalize()
.await?;

Ok(())
}

async fn get_blob_box<'a>(
client: &'a Box<dyn Client>,
container: &'a str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,9 @@ where

impl<'a, C> IncludeListOptions for ListBlobBuilder<'a, C, Yes> where C: Client {}

// methods callable only when every mandatory field has been filled
impl<'a, C> ListBlobBuilder<'a, C, Yes>
where
C: Client + Clone,
C: Client,
{
pub async fn finalize(self) -> Result<ListBlobsResponse, AzureError> {
// we create a copy to move into the future's closure.
Expand Down Expand Up @@ -584,7 +583,12 @@ where
.await?;
ListBlobsResponse::from_response(&container_name, &headers, &body_as_str)
}
}

impl<'a, C> ListBlobBuilder<'a, C, Yes>
where
C: Client + Clone,
{
pub fn stream(self) -> impl Stream<Item = Result<ListBlobsResponse, AzureError>> + 'a {
#[derive(Debug, Clone, PartialEq)]
enum States {
Expand Down

0 comments on commit ff2d844

Please sign in to comment.