Skip to content

remove Box<dyn Error + Send + Sync> from data_cosmos #819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sdk/data_cosmos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ should also be possible with this crate.
// Using the prelude module of the Cosmos crate makes easier to use the Rust Azure SDK for Cosmos DB.
use azure_data_cosmos::prelude::*;
use azure_core::Context;
use azure_core::error::Result;
use serde::{Deserialize, Serialize};
use std::error::Error;

// This is the stuct we want to use in our sample.
// Make sure to have a collection with partition key "a_number" for this example to
Expand All @@ -37,7 +37,7 @@ impl<'a> azure_data_cosmos::CosmosEntity<'a> for MySampleStruct {
// This code will perform these tasks:
// 1. Create 10 documents in the collection.
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
async fn main() -> Result<()> {
// Let's get Cosmos account and master key from env variables.
let master_key =
std::env::var("COSMOS_MASTER_KEY").expect("Set env variable COSMOS_MASTER_KEY first!");
Expand Down
4 changes: 2 additions & 2 deletions sdk/data_cosmos/examples/attachments_00.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use azure_core::error::Result;
use azure_data_cosmos::prelude::*;
use futures::StreamExt;
use serde::{Deserialize, Serialize};
use std::error::Error;

// Now we create a sample struct.
#[derive(Serialize, Deserialize, Clone, Debug)]
Expand All @@ -23,7 +23,7 @@ impl azure_data_cosmos::CosmosEntity for MySampleStruct {
// This example expects you to have created a collection
// with partitionKey on "id".
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
async fn main() -> Result<()> {
let database_name = std::env::args()
.nth(1)
.expect("please specify database name as first command line parameter");
Expand Down
4 changes: 2 additions & 2 deletions sdk/data_cosmos/examples/collection.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use azure_core::error::Result;
use azure_data_cosmos::prelude::*;
use futures::stream::StreamExt;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
async fn main() -> Result<()> {
// First we retrieve the account name and master key from environment variables.
// We expect master keys (ie, not resource constrained)
let master_key =
Expand Down
4 changes: 2 additions & 2 deletions sdk/data_cosmos/examples/create_delete_database.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use azure_core::error::Result;
use azure_data_cosmos::prelude::*;
use futures::stream::StreamExt;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
async fn main() -> Result<()> {
// First we retrieve the account name and master key from environment variables.
// We expect master keys (ie, not resource constrained)
let master_key =
Expand Down
4 changes: 2 additions & 2 deletions sdk/data_cosmos/examples/database_00.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use azure_core::error::Result;
use azure_data_cosmos::prelude::*;
use futures::stream::StreamExt;
use serde_json::Value;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
async fn main() -> Result<()> {
// First we retrieve the account name and master key from environment variables.
// We expect master keys (ie, not resource constrained)
let master_key =
Expand Down
4 changes: 2 additions & 2 deletions sdk/data_cosmos/examples/database_01.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use azure_core::error::Result;
use azure_data_cosmos::prelude::*;
use futures::stream::StreamExt;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
async fn main() -> Result<()> {
// First we retrieve the account name and master key from environment variables.
// We expect master keys (ie, not resource constrained)
let master_key =
Expand Down
4 changes: 2 additions & 2 deletions sdk/data_cosmos/examples/document_00.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use futures::stream::StreamExt;
use serde::{Deserialize, Serialize};
// Using the prelude module of the Cosmos crate makes easier to use the Rust Azure SDK for Cosmos
// DB.
use azure_core::error::Result;
use azure_core::prelude::*;
use azure_data_cosmos::prelude::*;
use std::error::Error;

#[derive(Clone, Serialize, Deserialize, Debug)]
struct MySampleStruct {
Expand Down Expand Up @@ -32,7 +32,7 @@ const COLLECTION: &str = "azuresdktc";
// 3. Store an entry in collection *COLLECTION* of database *DATABASE*.
// 4. Delete everything.
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
async fn main() -> Result<()> {
// Let's get Cosmos account and master key from env variables.
// This helps automated testing.
let master_key =
Expand Down
4 changes: 2 additions & 2 deletions sdk/data_cosmos/examples/document_entries_00.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use azure_core::error::Result;
use azure_core::prelude::*;
use azure_data_cosmos::prelude::*;
use futures::stream::StreamExt;
use serde::{Deserialize, Serialize};
use std::error::Error;

// Now we create a sample struct.
#[derive(Serialize, Deserialize, Clone, Debug)]
Expand All @@ -24,7 +24,7 @@ impl azure_data_cosmos::CosmosEntity for MySampleStruct {
// This example expects you to have created a collection
// with partitionKey on "id".
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
async fn main() -> Result<()> {
let database_name = std::env::args()
.nth(1)
.expect("please specify database name as first command line parameter");
Expand Down
4 changes: 2 additions & 2 deletions sdk/data_cosmos/examples/document_entries_01.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use azure_core::error::Result;
use azure_data_cosmos::prelude::*;
use futures::StreamExt;
use serde::{Deserialize, Serialize};
use std::error::Error;

#[derive(Serialize, Deserialize, Clone, Debug)]
struct MySampleStruct {
Expand All @@ -22,7 +22,7 @@ impl azure_data_cosmos::CosmosEntity for MySampleStruct {
// This example expects you to have created a collection
// with partitionKey on "id".
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
async fn main() -> Result<()> {
let database_name = std::env::args()
.nth(1)
.expect("please specify database name as first command line parameter");
Expand Down
4 changes: 2 additions & 2 deletions sdk/data_cosmos/examples/get_database.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use azure_core::error::Result;
use azure_core::headers::{HeaderName, HeaderValue, Headers};
use azure_core::prelude::*;
use azure_core::CustomHeaders;
use azure_data_cosmos::prelude::*;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
async fn main() -> Result<()> {
// First we retrieve the account name and master key from environment variables.
// We expect master keys (ie, not resource constrained)
let master_key =
Expand Down
4 changes: 2 additions & 2 deletions sdk/data_cosmos/examples/key_ranges_00.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use azure_core::error::Result;
use azure_data_cosmos::prelude::*;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
async fn main() -> Result<()> {
let database = std::env::args()
.nth(1)
.expect("please specify database name as first command line parameter");
Expand Down
4 changes: 2 additions & 2 deletions sdk/data_cosmos/examples/permission_00.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use azure_core::error::Result;
use azure_data_cosmos::prelude::*;
use futures::StreamExt;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
async fn main() -> Result<()> {
// First we retrieve the account name and master key from environment variables.
// We expect master keys (ie, not resource constrained)
let master_key =
Expand Down
4 changes: 2 additions & 2 deletions sdk/data_cosmos/examples/query_document_00.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use azure_core::error::Result;
use azure_data_cosmos::prelude::*;
use futures::StreamExt;
use serde::{Deserialize, Serialize};
use std::error::Error;

#[derive(Serialize, Deserialize, Debug)]
struct MySampleStructOwned {
Expand All @@ -20,7 +20,7 @@ struct MySecondSampleStructOwned {
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
async fn main() -> Result<()> {
let database_name = std::env::args()
.nth(1)
.expect("please specify database name as first command line parameter");
Expand Down
4 changes: 2 additions & 2 deletions sdk/data_cosmos/examples/readme.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use serde::{Deserialize, Serialize};
// Using the prelude module of the Cosmos crate makes easier to use the Rust Azure SDK for Cosmos.
use azure_core::error::Result;
use azure_data_cosmos::prelude::*;
use futures::stream::StreamExt;
use std::error::Error;

// This is the stuct we want to use in our sample.
// Make sure to have a collection with partition key "a_number" for this example to
Expand Down Expand Up @@ -31,7 +31,7 @@ impl azure_data_cosmos::CosmosEntity for MySampleStruct {
// 4. Delete the documents returned by task 4.
// 5. Check the remaining documents.
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
async fn main() -> Result<()> {
// Let's get Cosmos account and master key from env variables.
// This helps automated testing.
let master_key =
Expand Down
4 changes: 2 additions & 2 deletions sdk/data_cosmos/examples/remove_all_documents.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use azure_core::error::Result;
use azure_data_cosmos::prelude::*;
use futures::stream::StreamExt;
use serde_json::Value;
use std::error::Error;

// This example expects you to have created a collection
// with partitionKey on "id".
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
async fn main() -> Result<()> {
let database_name = std::env::args()
.nth(1)
.expect("please specify the database name as first command line parameter");
Expand Down
4 changes: 2 additions & 2 deletions sdk/data_cosmos/examples/stored_proc_00.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use azure_core::error::Result;
/// This sample showcases execution of stored procedure
/// Create stored procedure called test_proc, like so:
/// function f(personToGreet) {
Expand All @@ -6,10 +7,9 @@
/// response.setBody("Hello, " + personToGreet);
/// }
use azure_data_cosmos::prelude::*;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
async fn main() -> Result<()> {
let database = std::env::args()
.nth(1)
.expect("please specify database name as first command line parameter");
Expand Down
4 changes: 2 additions & 2 deletions sdk/data_cosmos/examples/stored_proc_01.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use azure_core::error::Result;
/// This sample showcases execution of stored procedure
/// Create stored procedure called test_proc, like so:
/// function f(personToGreet) {
Expand All @@ -7,10 +8,9 @@
/// }
use azure_data_cosmos::prelude::*;
use futures::StreamExt;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
async fn main() -> Result<()> {
let function_body: &str = r#"
function f(personToGreet) {
var context = getContext();
Expand Down
4 changes: 2 additions & 2 deletions sdk/data_cosmos/examples/trigger_00.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use azure_core::error::Result;
use azure_data_cosmos::prelude::*;
use azure_data_cosmos::resources::trigger::{TriggerOperation, TriggerType};
use futures::stream::StreamExt;
use std::error::Error;

const TRIGGER_BODY: &str = r#"
function updateMetadata() {
Expand Down Expand Up @@ -34,7 +34,7 @@ function updateMetadata() {
}"#;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
async fn main() -> Result<()> {
let database = std::env::args()
.nth(1)
.expect("please specify database name as first command line parameter");
Expand Down
4 changes: 2 additions & 2 deletions sdk/data_cosmos/examples/user_00.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use azure_core::error::Result;
use azure_data_cosmos::prelude::*;
use futures::StreamExt;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
async fn main() -> Result<()> {
// First we retrieve the account name and master key from environment variables.
// We expect master keys (ie, not resource constrained)
let master_key =
Expand Down
4 changes: 2 additions & 2 deletions sdk/data_cosmos/examples/user_defined_function_00.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use azure_core::error::Result;
use azure_data_cosmos::prelude::*;
use futures::stream::StreamExt;
use std::error::Error;

const FN_BODY: &str = r#"
function tax(income) {
Expand All @@ -15,7 +15,7 @@ function tax(income) {
}"#;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
async fn main() -> Result<()> {
let database = std::env::args()
.nth(1)
.expect("please specify database name as first command line parameter");
Expand Down
4 changes: 2 additions & 2 deletions sdk/data_cosmos/examples/user_permission_token.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use azure_core::error::Result;
use azure_data_cosmos::prelude::*;
use futures::StreamExt;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
async fn main() -> Result<()> {
// First we retrieve the account name and master key from environment variables.
// We expect master keys (ie, not resource constrained)
let master_key =
Expand Down
4 changes: 2 additions & 2 deletions sdk/data_cosmos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ should also be possible with this crate.
use azure_data_cosmos::prelude::*;
use azure_core::Context;
use serde::{Deserialize, Serialize};
use std::error::Error;
use azure_core::error::Result;

// This is the stuct we want to use in our sample.
// Make sure to have a collection with partition key "a_number" for this example to
Expand All @@ -41,7 +41,7 @@ impl azure_data_cosmos::CosmosEntity for MySampleStruct {
// This code will perform these tasks:
// 1. Create 10 documents in the collection.
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
async fn main() -> Result<()> {
// Let's get Cosmos account and master key from env variables.
let master_key =
std::env::var("COSMOS_MASTER_KEY").expect("Set env variable COSMOS_MASTER_KEY first!");
Expand Down
5 changes: 2 additions & 3 deletions sdk/data_cosmos/tests/collection_operations.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#![cfg(feature = "mock_transport_framework")]

use azure_core::error::Result;
use azure_data_cosmos::resources::collection::*;
use futures::StreamExt;

mod setup;

type BoxedError = Box<dyn std::error::Error + Send + Sync>;

#[tokio::test]
async fn collection_operations() -> Result<(), BoxedError> {
async fn collection_operations() -> Result<()> {
env_logger::init();

let client = setup::initialize("collection_operations")?;
Expand Down
5 changes: 2 additions & 3 deletions sdk/data_cosmos/tests/database_operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

mod setup;

use azure_core::error::Result;
use futures::StreamExt;

pub type BoxedError = Box<dyn std::error::Error + Send + Sync>;

#[tokio::test]
async fn database_operations() -> Result<(), BoxedError> {
async fn database_operations() -> Result<()> {
const DATABASE_NAME: &str = "cosmos-test-db-create-and-delete-database";

let client = setup::initialize("database_operations")?;
Expand Down