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

Commit 1aa53a3

Browse files
authored
Merge pull request #124 from MindFlavor/crate_split/pr
Crate split
2 parents b193d84 + e5cb40a commit 1aa53a3

File tree

162 files changed

+1284
-1041
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+1284
-1041
lines changed

Cargo.toml

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,9 @@
1-
[package]
2-
name = "azure_sdk_for_rust"
3-
version = "0.12.0"
4-
description = "Rust wrappers around Microsoft Azure REST APIs"
5-
readme = "README.md"
6-
authors = ["Francesco Cogno <francesco.cogno@outlook.com>", "Max Gortman <mgortman@microsoft.com>", "Dong Liu <doliu@microsoft.com>"]
7-
license = "Apache-2.0"
8-
repository = "https://github.com/MindFlavor/AzureSDKForRust"
9-
documentation = "http://mindflavor.github.io/AzureSDKForRust/azure_sdk_for_rust/index.html"
10-
homepage = "https://github.com/MindFlavor/AzureSDKForRust"
11-
12-
keywords = ["sdk", "azure", "rest", "iot", "cloud"]
13-
categories = ["api-bindings"]
14-
15-
edition = "2018"
16-
17-
[dependencies]
18-
ring = "0.14"
19-
md5 = "0.6"
20-
RustyXML = "0.1"
21-
base64 = "0.10"
22-
chrono = "0.4"
23-
env_logger = "0.6"
24-
futures = "0.1"
25-
http = "0.1"
26-
hyper = "0.12"
27-
log = "0.4"
28-
mime = "0.3"
29-
quick-error = "1.2"
30-
serde = "1.0"
31-
serde_derive = "1.0"
32-
serde_json = "1.0"
33-
serde-xml-rs = "0.3"
34-
time = "0.1"
35-
url = "1.7"
36-
uuid = { version = "0.7", features = ["v4"] }
37-
smallvec = { version = "0.6", features = ["serde"] }
38-
bytes = "0.4"
39-
hyper-rustls = "0.16"
40-
41-
[dev-dependencies]
42-
tokio-core = "0.1"
43-
44-
[features]
45-
test_e2e = []
1+
[workspace]
2+
members = [
3+
"azure_sdk_core",
4+
"azure_sdk_cosmos",
5+
"azure_sdk_service_bus",
6+
"azure_sdk_storage_blob",
7+
"azure_sdk_storage_core",
8+
"azure_sdk_storage_table"
9+
]

README.md

Lines changed: 47 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# Microsoft Azure SDK for Rust
22

3-
[![docs](https://docs.rs/azure_sdk_for_rust/badge.svg)](https://docs.rs/azure_sdk_for_rust/0.12.0/azure_sdk_for_rust)
3+
[![docs](https://docs.rs/azure_sdk_for_rust/badge.svg)](https://docs.rs/azure_sdk_for_rust/0.20.0/azure_sdk_for_rust)
44

55
[![legal](https://img.shields.io/github/license/mindflavor/AzureSDKForRust.svg)](LICENSE)
66

77
[![Build Status](https://travis-ci.org/MindFlavor/AzureSDKForRust.svg?branch=master)](https://travis-ci.org/MindFlavor/AzureSDKForRust) [![Coverage Status](https://coveralls.io/repos/MindFlavor/AzureSDKForRust/badge.svg?branch=master&service=github)](https://coveralls.io/github/MindFlavor/AzureSDKForRust?branch=master) ![stability-unstable](https://img.shields.io/badge/stability-unstable-yellow.svg)
88

99
[![Crate](https://img.shields.io/crates/v/azure_sdk_for_rust.svg)](https://crates.io/crates/azure_sdk_for_rust) [![cratedown](https://img.shields.io/crates/d/azure_sdk_for_rust.svg)](https://crates.io/crates/azure_sdk_for_rust) [![cratelastdown](https://img.shields.io/crates/dv/azure_sdk_for_rust.svg)](https://crates.io/crates/azure_sdk_for_rust)
1010

11-
[![tag](https://img.shields.io/github/tag/mindflavor/AzureSDKForRust.svg)](https://github.com/MindFlavor/AzureSDKForRust/tree/0.12.0)
12-
[![release](https://img.shields.io/github/release/mindflavor/AzureSDKForRust.svg)](https://github.com/MindFlavor/AzureSDKForRust/releases/tag/0.12.0)
13-
[![commitssince](https://img.shields.io/github/commits-since/mindflavor/AzureSDKForRust/0.12.0.svg)](https://github.com/MindFlavor/AzureSDKForRust/commits/master)
11+
[![tag](https://img.shields.io/github/tag/mindflavor/AzureSDKForRust.svg)](https://github.com/MindFlavor/AzureSDKForRust/tree/0.20.0)
12+
[![release](https://img.shields.io/github/release/mindflavor/AzureSDKForRust.svg)](https://github.com/MindFlavor/AzureSDKForRust/releases/tag/0.20.0)
13+
[![commitssince](https://img.shields.io/github/commits-since/mindflavor/AzureSDKForRust/0.20.0.svg)](https://github.com/MindFlavor/AzureSDKForRust/commits/master)
1414

1515
[![GitHub contributors](https://img.shields.io/github/contributors/MindFlavor/AzureSDKForRust.svg)](https://github.com/MindFlavor/AzureSDKForRust/graphs/contributors)
1616

@@ -25,6 +25,19 @@ From version 0.12.0 the library switched from [hyper-tls](https://github.com/hyp
2525

2626
> **NOTE:** This repository is under heavy development and is likely to break over time. The current releases will probabily contain bugs. As usual open issues if you find any.
2727
28+
## Upgrading from 0.12.0
29+
30+
Starting from version `0.20.0` the monolithic crate has been split in several smaller, more manageable, crates. This means you will have to update both your `Cargo.toml` and your `use` statements to use the new version. The crate's names are as follows:
31+
32+
* [azure_sdk_core](azure_sdk_core)
33+
* [azure_sdk_cosmos](azure_sdk_cosmos)
34+
* [azure_sdk_service_bus](azure_sdk_service_bus)
35+
* [azure_sdk_storage_blob](azure_sdk_storage_blob)
36+
* [azure_sdk_storage_core](azure_sdk_storage_core)
37+
* [azure_sdk_storage_table](azure_sdk_storage_table)
38+
39+
The names should be self-explanatory; the examples have been updated to use the new crate topology. In case of doubt please do not hesitate to open an issue. As for the functionality, the release `0.20.0` is equivalent to the `0.12.0` so you can migrate to the new crate topology without embedding extra bugs (hopefully! :wink:).
40+
2841
## Disclaimer
2942
Although I am a Microsoft employee, this is not a Microsoft endorsed project. It's simply a pet project of mine: I love Rust (who doesn't? :smirk:) and Microsoft Azure technologies so I thought to close the gap between them. It's also a good project for learning Rust. This library relies heavily on [Hyper](https://github.com/hyperium/hyper). We use the latest Hyper code so this library is fully async with Futures and Tokio.
3043

@@ -34,25 +47,14 @@ You can find examples in the [```examples```](https://github.com/MindFlavor/Azur
3447
### main.rs
3548

3649
```rust
37-
extern crate azure_sdk_for_rust;
38-
39-
extern crate chrono;
40-
extern crate futures;
41-
extern crate hyper;
42-
extern crate hyper_tls;
43-
extern crate tokio;
44-
extern crate tokio_core;
45-
46-
use std::error::Error;
47-
48-
use futures::future::*;
49-
use tokio_core::reactor::Core;
50-
51-
use azure_sdk_for_rust::cosmos::{AuthorizationToken, Client, TokenType};
52-
5350
#[macro_use]
5451
extern crate serde_derive;
55-
use azure_sdk_for_rust::cosmos;
52+
// Using the prelude module of the Cosmos crate makes easier to use the Rust Azure SDK for Cosmos
53+
// DB.
54+
use azure_sdk_cosmos::prelude::*;
55+
use futures::future::*;
56+
use std::error::Error;
57+
use tokio_core::reactor::Core;
5658

5759
#[derive(Serialize, Deserialize, Debug)]
5860
struct MySampleStruct<'a> {
@@ -62,14 +64,8 @@ struct MySampleStruct<'a> {
6264
a_timestamp: i64,
6365
}
6466

65-
// Following the official azure cosmos db tutorial: https://docs.microsoft.com/pt-br/azure/cosmos-db/sql-api-dotnetcore-get-started
66-
// Master key is the Primary Key from Keys section in your CosmosDB screen
67-
// Account is the first part of URI from Keys section, if your URI is https://test.documents.azure.com:443/ the account is test
68-
// DATABASES are the base objects in your Data Explorer section
69-
// COLLECTIONS are the objects inside the DATABASES
70-
71-
const DATABASE: &'static str = "azuresdktestdb";
72-
const COLLECTION: &'static str = "azuresdktc";
67+
const DATABASE: &str = "azuresdktestdb";
68+
const COLLECTION: &str = "azuresdktc";
7369

7470
fn main() {
7571
code().unwrap();
@@ -85,13 +81,11 @@ fn main() {
8581
// We will use multiple futures for this hoping to make the code clearer.
8682
// There is no need to proceed this way in your code.
8783
// You can go crazy with future combinators if you want to :)
88-
fn code() -> Result<(), Box<Error>> {
84+
fn code() -> Result<(), Box<dyn Error>> {
8985
// Let's get Cosmos account and master key from env variables.
9086
// This helps automated testing.
91-
let master_key =
92-
std::env::var("COSMOSDB_MASTER_KEY").expect("Set env variable COSMOS_MASTER_KEY first!");
93-
let account =
94-
std::env::var("COSMOSDB_ACCOUNT").expect("Set env variable COSMOS_ACCOUNT first!");
87+
let master_key = std::env::var("COSMOS_MASTER_KEY").expect("Set env variable COSMOS_MASTER_KEY first!");
88+
let account = std::env::var("COSMOS_ACCOUNT").expect("Set env variable COSMOS_ACCOUNT first!");
9589

9690
// First, we create an authorization token. There are two types of tokens, master and resource
9791
// constrained. Please check the Azure documentation for details. You can change tokens
@@ -125,35 +119,35 @@ fn code() -> Result<(), Box<Error>> {
125119
// we will create it. The collection creation is more complex and
126120
// has many options (such as indexing and so on).
127121
let collection = {
128-
let collections = core.run(client.list_collections(&DATABASE))?;
122+
let collections = core.run(client.list_collections(&database.id))?;
129123

130124
if let Some(collection) = collections.into_iter().find(|coll| coll.id == COLLECTION) {
131125
collection
132126
} else {
133-
let indexes = cosmos::collection::IncludedPathIndex {
134-
kind: cosmos::collection::KeyKind::Hash,
135-
data_type: cosmos::collection::DataType::String,
127+
let indexes = IncludedPathIndex {
128+
kind: KeyKind::Hash,
129+
data_type: DataType::String,
136130
precision: Some(3),
137131
};
138132

139-
let ip = cosmos::collection::IncludedPath {
133+
let ip = IncludedPath {
140134
path: "/*".to_owned(),
141135
indexes: vec![indexes],
142136
};
143137

144-
let ip = cosmos::collection::IndexingPolicy {
138+
let ip = IndexingPolicy {
145139
automatic: true,
146-
indexing_mode: cosmos::collection::IndexingMode::Consistent,
140+
indexing_mode: IndexingMode::Consistent,
147141
included_paths: vec![ip],
148142
excluded_paths: vec![],
149143
};
150144

151-
let coll = cosmos::collection::Collection::new(COLLECTION, ip);
145+
let coll = Collection::new(COLLECTION, ip);
152146
// Notice here we specify the expected performance level.
153147
// Performance levels have price impact. Also, higher
154148
// performance levels force you to specify an indexing
155149
// strategy. Consult the documentation for more details.
156-
core.run(client.create_collection(&DATABASE, 400, &coll))?
150+
core.run(client.create_collection(&database.id, 400, &coll))?
157151
}
158152
};
159153

@@ -173,15 +167,11 @@ fn code() -> Result<(), Box<Error>> {
173167
// Notice how easy it is! :)
174168
// The method create_document will return, upon success,
175169
// the document attributes.
176-
let document_attributes = core.run(
177-
client
178-
.create_document(&DATABASE, &COLLECTION, &doc)
179-
.execute(),
180-
)?;
170+
let document_attributes = core.run(client.create_document(&database.id, &collection.id, &doc).execute())?;
181171
println!("document_attributes == {:?}", document_attributes);
182172

183173
// We will perform some cleanup. First we delete the collection...
184-
core.run(client.delete_collection(DATABASE, &COLLECTION))?;
174+
core.run(client.delete_collection(DATABASE, COLLECTION))?;
185175
println!("collection deleted");
186176

187177
// And then we delete the database.
@@ -303,6 +293,10 @@ export AZURE_EVENT_HUB_NAME=<azure_event_hub_name>
303293
export AZURE_POLICY_NAME=<azure_policy_name>
304294
export AZURE_POLICY_KEY=<azure policy key>
305295

296+
cd azure_sdk_service_bus
297+
cargo test --features=test_e2e
298+
299+
cd ../azure_sdk_storage_blob
306300
cargo test --features=test_e2e
307301
```
308302

@@ -317,6 +311,10 @@ set AZURE_EVENT_HUB_NAME=<azure_event_hub_name>
317311
set AZURE_POLICY_NAME=<azure_policy_name>
318312
set AZURE_POLICY_KEY=<azure policy key>
319313
314+
cd azure_sdk_service_bus
315+
cargo test --features=test_e2e
316+
317+
cd ../azure_sdk_storage_blob
320318
cargo test --features=test_e2e
321319
```
322320

azure_sdk_core/Cargo.toml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[package]
2+
name = "azure_sdk_core"
3+
version = "0.20.0"
4+
description = "Rust wrappers around Microsoft Azure REST APIs - Core crate"
5+
readme = "README.md"
6+
authors = ["Francesco Cogno <francesco.cogno@outlook.com>", "Max Gortman <mgortman@microsoft.com>", "Dong Liu <doliu@microsoft.com>"]
7+
license = "Apache-2.0"
8+
repository = "https://github.com/MindFlavor/AzureSDKForRust"
9+
documentation = "http://mindflavor.github.io/AzureSDKForRust/azure_sdk_for_rust/index.html"
10+
homepage = "https://github.com/MindFlavor/AzureSDKForRust"
11+
12+
keywords = ["sdk", "azure", "rest", "iot", "cloud"]
13+
categories = ["api-bindings"]
14+
15+
edition = "2018"
16+
17+
[dependencies]
18+
ring = "0.14"
19+
md5 = "0.6"
20+
RustyXML = "0.1"
21+
base64 = "0.10"
22+
chrono = "0.4"
23+
env_logger = "0.6"
24+
futures = "0.1"
25+
http = "0.1"
26+
hyper = "0.12"
27+
log = "0.4"
28+
mime = "0.3"
29+
quick-error = "1.2"
30+
serde = "1.0"
31+
serde_derive = "1.0"
32+
serde_json = "1.0"
33+
serde-xml-rs = "0.3"
34+
time = "0.1"
35+
url = "1.7"
36+
uuid = { version = "0.7", features = ["v4"] }
37+
smallvec = { version = "0.6", features = ["serde"] }
38+
bytes = "0.4"
39+
hyper-rustls = "0.16"
40+
41+
[dev-dependencies]
42+
tokio-core = "0.1"
43+
44+
[features]
45+
test_e2e = []
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::azure::core::errors::{Not512ByteAlignedError, Parse512AlignedError};
2-
use crate::azure::core::range::Range;
1+
use crate::errors::{Not512ByteAlignedError, Parse512AlignedError};
2+
use crate::range::Range;
33
use std::convert::Into;
44
use std::fmt;
55
use std::str::FromStr;
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub enum ParsingError {
55

66
/// use as
77
/// ```create_enum!(SecondCollection, (Pollo, "Pollo"), (Bianco, "Bianco"), (Giallo, "Giallo"));```
8+
#[macro_export]
89
macro_rules! create_enum {
910
($en:ident, $(($na:ident, $x:expr)), *) => (
1011
#[derive(Debug, PartialEq, PartialOrd, Clone, Copy)]
@@ -70,9 +71,9 @@ macro_rules! create_enum {
7071

7172
#[cfg(test)]
7273
mod test {
73-
use crate::azure::core::enumerations;
74-
use crate::azure::core::errors::TraversingError;
75-
use crate::azure::core::parsing::FromStringOptional;
74+
use crate::enumerations;
75+
use crate::errors::TraversingError;
76+
use crate::parsing::FromStringOptional;
7677
use std::fmt;
7778
use std::str::FromStr;
7879

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::azure::core::{enumerations::ParsingError, range::ParseError};
1+
use crate::{enumerations::ParsingError, range::ParseError};
22
use base64;
33
use chrono;
44
use futures::{Future, Stream};
@@ -72,7 +72,7 @@ impl std::error::Error for UnexpectedHTTPResult {
7272
"Unexpected HTTP result"
7373
}
7474

75-
fn cause(&self) -> Option<&std::error::Error> {
75+
fn cause(&self) -> Option<&dyn std::error::Error> {
7676
None
7777
}
7878
}
@@ -287,7 +287,7 @@ impl From<()> for AzureError {
287287
}
288288

289289
#[inline]
290-
pub(crate) fn extract_status_headers_and_body(
290+
pub fn extract_status_headers_and_body(
291291
resp: hyper::client::ResponseFuture,
292292
) -> impl Future<Item = (hyper::StatusCode, hyper::HeaderMap, hyper::Chunk), Error = AzureError> {
293293
resp.from_err().and_then(|res| {
@@ -299,7 +299,7 @@ pub(crate) fn extract_status_headers_and_body(
299299
}
300300

301301
#[inline]
302-
pub(crate) fn check_status_extract_headers_and_body(
302+
pub fn check_status_extract_headers_and_body(
303303
resp: hyper::client::ResponseFuture,
304304
expected_status_code: hyper::StatusCode,
305305
) -> impl Future<Item = (hyper::HeaderMap, hyper::Chunk), Error = AzureError> {
@@ -317,7 +317,7 @@ pub(crate) fn check_status_extract_headers_and_body(
317317
}
318318

319319
#[inline]
320-
pub(crate) fn check_status_extract_headers_and_body_as_string(
320+
pub fn check_status_extract_headers_and_body_as_string(
321321
resp: hyper::client::ResponseFuture,
322322
expected_status_code: hyper::StatusCode,
323323
) -> impl Future<Item = (hyper::HeaderMap, String), Error = AzureError> {
@@ -328,7 +328,7 @@ pub(crate) fn check_status_extract_headers_and_body_as_string(
328328
}
329329

330330
#[inline]
331-
pub(crate) fn extract_status_and_body(resp: hyper::client::ResponseFuture) -> impl Future<Item = (StatusCode, String), Error = AzureError> {
331+
pub fn extract_status_and_body(resp: hyper::client::ResponseFuture) -> impl Future<Item = (StatusCode, String), Error = AzureError> {
332332
resp.from_err().and_then(|res| {
333333
let status = res.status();
334334
res.into_body()
@@ -339,7 +339,7 @@ pub(crate) fn extract_status_and_body(resp: hyper::client::ResponseFuture) -> im
339339
}
340340

341341
#[inline]
342-
pub(crate) fn check_status_extract_body(
342+
pub fn check_status_extract_body(
343343
resp: hyper::client::ResponseFuture,
344344
expected_status_code: hyper::StatusCode,
345345
) -> impl Future<Item = String, Error = AzureError> {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use crate::azure::core::enumerations;
2-
use crate::azure::core::errors::TraversingError;
3-
use crate::azure::core::parsing::FromStringOptional;
1+
use crate::enumerations;
2+
use crate::errors::TraversingError;
3+
use crate::parsing::FromStringOptional;
44
use std::fmt;
55
use std::str::FromStr;
66
use uuid::Uuid;

0 commit comments

Comments
 (0)