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

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
MindFlavor committed Jun 19, 2020
2 parents 2840b07 + 0a0f83a commit a6e96ba
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 8 deletions.
4 changes: 2 additions & 2 deletions azure_sdk_storage_account/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "azure_sdk_storage_account"
version = "0.41.0"
version = "0.41.1"
description = "Rust wrappers around Microsoft Azure REST APIs - Blob storage account crate"
readme = "README.md"
authors = ["Francesco Cogno <[email protected]>", "Max Gortman <[email protected]>"]
Expand All @@ -16,7 +16,7 @@ edition = "2018"

[dependencies]
azure_sdk_core = { path = "../azure_sdk_core", version = "0.43.4" }
azure_sdk_storage_core = { path = "../azure_sdk_storage_core", version = "0.44.0" }
azure_sdk_storage_core = { path = "../azure_sdk_storage_core", version = "0.44.1" }
chrono = "0.4"
http = "0.2"
hyper = "0.13"
Expand Down
4 changes: 2 additions & 2 deletions 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.44.0"
version = "0.44.1"
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 All @@ -16,7 +16,7 @@ edition = "2018"

[dependencies]
azure_sdk_core = { path = "../azure_sdk_core", version = "0.43.4" }
azure_sdk_storage_core = { path = "../azure_sdk_storage_core", version = "0.44.0" }
azure_sdk_storage_core = { path = "../azure_sdk_storage_core", version = "0.44.1" }
md5 = "0.7"
RustyXML = "0.3"
base64 = "0.12"
Expand Down
2 changes: 1 addition & 1 deletion azure_sdk_storage_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "azure_sdk_storage_core"
version = "0.44.0"
version = "0.44.1"
description = "Rust wrappers around Microsoft Azure REST APIs - Core storage crate"
readme = "README.md"
authors = ["Francesco Cogno <[email protected]>", "Max Gortman <[email protected]>", "Dong Liu <[email protected]>"]
Expand Down
22 changes: 22 additions & 0 deletions azure_sdk_storage_core/examples/box.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use azure_sdk_storage_core::prelude::*;
use std::thread;

fn get_box() -> Box<dyn Client> {
Box::new(client::with_access_key("fake", "fake"))
}

fn get_box_send() -> Box<dyn Client + Send + Sync> {
Box::new(client::with_access_key("fake", "fake"))
}

pub fn main() {
let client = get_box();
println!("client.blob_uri() == {}", client.blob_uri());

let client_send = get_box_send();

let handler = thread::spawn(move || {
println!("client_send.blob_uri() == {}", client_send.blob_uri());
});
handler.join().unwrap();
}
36 changes: 35 additions & 1 deletion azure_sdk_storage_core/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub trait HttpHeaderAdder {
fn add_headers(&self, builder: ::http::request::Builder) -> ::http::request::Builder;
}

pub trait Client {
pub trait Client: Send + Sync {
fn blob_uri(&self) -> &str;
fn table_uri(&self) -> &str;

Expand Down Expand Up @@ -43,6 +43,40 @@ pub trait Client {
) -> Result<hyper::client::ResponseFuture, AzureError>;
}

impl<C> Client for Box<C>
where
C: Client,
{
fn blob_uri(&self) -> &str {
self.as_ref().blob_uri()
}
fn table_uri(&self) -> &str {
self.as_ref().table_uri()
}

fn perform_request(
&self,
uri: &str,
method: &Method,
http_header_adder: &dyn Fn(Builder) -> Builder,
request_body: Option<&[u8]>,
) -> Result<hyper::client::ResponseFuture, AzureError> {
self.as_ref()
.perform_request(uri, method, http_header_adder, request_body)
}

fn perform_table_request(
&self,
segment: &str,
method: &Method,
http_header_adder: &dyn Fn(Builder) -> Builder,
request_str: Option<&[u8]>,
) -> Result<hyper::client::ResponseFuture, AzureError> {
self.as_ref()
.perform_table_request(segment, method, http_header_adder, request_str)
}
}

impl Client for Box<dyn Client> {
fn blob_uri(&self) -> &str {
self.as_ref().blob_uri()
Expand Down
4 changes: 2 additions & 2 deletions azure_sdk_storage_table/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "azure_sdk_storage_table"
version = "0.41.0"
version = "0.41.1"
description = "Rust wrappers around Microsoft Azure REST APIs - Table storage crate"
readme = "README.md"
authors = ["Francesco Cogno <[email protected]>", "gzp-crey", "Max Gortman <[email protected]>", "Dong Liu <[email protected]>"]
Expand All @@ -16,7 +16,7 @@ edition = "2018"

[dependencies]
azure_sdk_core = { path = "../azure_sdk_core", version = "0.43.4" }
azure_sdk_storage_core = { path = "../azure_sdk_storage_core", version = "0.44.0" }
azure_sdk_storage_core = { path = "../azure_sdk_storage_core", version = "0.44.1" }
chrono = "0.4"
http = "0.2"
hyper = "0.13"
Expand Down

0 comments on commit a6e96ba

Please sign in to comment.