From 3224ac6aa5edbfa22eb7a6bdf53f33e15faf1a49 Mon Sep 17 00:00:00 2001 From: Francesco Cogno Date: Sun, 1 Dec 2019 23:48:02 +0100 Subject: [PATCH] migrated to std::future after PR 173 --- azure_sdk_storage_table/Cargo.toml | 2 +- azure_sdk_storage_table/src/table/batch.rs | 14 ++++- azure_sdk_storage_table/src/table/mod.rs | 65 +++++++++++++--------- 3 files changed, 53 insertions(+), 28 deletions(-) diff --git a/azure_sdk_storage_table/Cargo.toml b/azure_sdk_storage_table/Cargo.toml index c985983f3..62e52f2c1 100644 --- a/azure_sdk_storage_table/Cargo.toml +++ b/azure_sdk_storage_table/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "azure_sdk_storage_table" -version = "0.30.0" +version = "0.30.1" description = "Rust wrappers around Microsoft Azure REST APIs - Table storage crate" readme = "README.md" authors = ["Francesco Cogno ", "Max Gortman ", "Dong Liu "] diff --git a/azure_sdk_storage_table/src/table/batch.rs b/azure_sdk_storage_table/src/table/batch.rs index d0b3c01da..64a7bc52e 100644 --- a/azure_sdk_storage_table/src/table/batch.rs +++ b/azure_sdk_storage_table/src/table/batch.rs @@ -31,7 +31,12 @@ impl BatchItem { } } -pub fn generate_batch_payload(uri_prefix: &str, table: &str, primary_key: &str, items: &[BatchItem]) -> String { +pub fn generate_batch_payload( + uri_prefix: &str, + table: &str, + primary_key: &str, + items: &[BatchItem], +) -> String { let mut payload: String = BATCH_BEGIN.to_owned(); for item in items { payload.push_str(CHANGESET_BEGIN); @@ -107,7 +112,12 @@ If-Match: * bupdate("Channel_17", "3", 9, "PDC 2008..."), bdelete("3"), ]; - let actual = generate_batch_payload("https://myaccount.table.core.windows.net/", "Blogs", "Channel_17", items.as_slice()); + let actual = generate_batch_payload( + "https://myaccount.table.core.windows.net/", + "Blogs", + "Channel_17", + items.as_slice(), + ); assert_eq!(expected, actual); } diff --git a/azure_sdk_storage_table/src/table/mod.rs b/azure_sdk_storage_table/src/table/mod.rs index 543c9b231..8dd2154af 100644 --- a/azure_sdk_storage_table/src/table/mod.rs +++ b/azure_sdk_storage_table/src/table/mod.rs @@ -339,69 +339,84 @@ pub struct TableStorage { } impl TableStorage { - pub fn new>(service: TableService, table_name: S) -> Self { - TableStorage { - service, - table_name: table_name.into() + pub fn new>(service: TableService, table_name: S) -> Self { + TableStorage { + service, + table_name: table_name.into(), } } - pub fn create_table(&self) -> impl Future { - self.service.create_table(self.table_name.clone()) + pub async fn create_table(&self) -> Result<(), AzureError> { + self.service.create_table(self.table_name.clone()).await } - pub fn get_entity( + pub async fn get_entity( &self, partition_key: &str, row_key: &str, - ) -> impl Future, Error = AzureError> { - self.service.get_entity(&self.table_name, partition_key, row_key) + ) -> Result, AzureError> { + self.service + .get_entity(&self.table_name, partition_key, row_key) + .await } - pub fn query_entities( + pub async fn query_entities( &self, query: Option<&str>, - ) -> impl Future, Error = AzureError> { - self.service.query_entities(&self.table_name, query) + ) -> Result, AzureError> { + self.service.query_entities(&self.table_name, query).await } pub fn stream_query_entities<'a, T: DeserializeOwned + 'a>( &'a self, query: Option<&'a str>, - ) -> impl Stream + 'a { + ) -> impl Stream, AzureError>> + 'a { self.service.stream_query_entities(&self.table_name, query) } pub fn stream_query_entities_fullmetadata<'a, T: DeserializeOwned + 'a>( &'a self, query: Option<&'a str>, - ) -> impl Stream + 'a { - self.service.stream_query_entities_fullmetadata(&self.table_name, query) + ) -> impl Stream, AzureError>> + 'a { + self.service + .stream_query_entities_fullmetadata(&self.table_name, query) } - pub fn insert_entity(&self, entity: &T) -> impl Future { - self.service.insert_entity::(&self.table_name, entity) + pub async fn insert_entity(&self, entity: &T) -> Result<(), AzureError> { + self.service + .insert_entity::(&self.table_name, entity) + .await } - pub fn update_entity( + pub async fn update_entity( &self, partition_key: &str, row_key: &str, entity: &T, - ) -> impl Future { - self.service.update_entity(&self.table_name, partition_key, row_key, entity) + ) -> Result<(), AzureError> { + self.service + .update_entity(&self.table_name, partition_key, row_key, entity) + .await } - pub fn delete_entity(&self, partition_key: &str, row_key: &str) -> impl Future { - self.service.delete_entity(&self.table_name, partition_key, row_key) + pub async fn delete_entity( + &self, + partition_key: &str, + row_key: &str, + ) -> Result<(), AzureError> { + self.service + .delete_entity(&self.table_name, partition_key, row_key) + .await } - pub fn batch( + pub async fn batch( &self, partition_key: &str, batch_items: &[BatchItem], - ) -> impl Future { - self.service.batch(&self.table_name, partition_key, batch_items) + ) -> Result<(), AzureError> { + self.service + .batch(&self.table_name, partition_key, batch_items) + .await } }