Skip to content

Commit 308975b

Browse files
committed
a few more tidy-ups
1 parent 8049e8e commit 308975b

File tree

6 files changed

+19
-32
lines changed

6 files changed

+19
-32
lines changed

sdk/cosmosdb/azure_data_cosmos/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ license.workspace = true
99
repository.workspace = true
1010
rust-version.workspace = true
1111
homepage = "https://github.com/azure/azure-sdk-for-rust"
12-
documentation = "https://docs.rs/azure_identity"
13-
keywords = ["sdk", "azure", "rest", "iot", "cloud"]
12+
documentation = "https://docs.rs/azure_data_cosmos"
13+
keywords = ["sdk", "azure", "rest", "cloud", "cosmosdb", "database"]
1414
categories = ["api-bindings"]
1515

1616
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

sdk/cosmosdb/azure_data_cosmos/examples/cosmosdb_connect.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// REVIEW: Don't merge this file. It's just for adhoc testing purposes.
2-
31
use azure_data_cosmos::{CosmosClient, CosmosClientMethods, DatabaseClientMethods};
42
use clap::Parser;
53

sdk/cosmosdb/azure_data_cosmos/src/clients/cosmos_client.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,17 @@ pub struct CosmosClient {
1717
options: CosmosClientOptions,
1818
}
1919

20+
/// Defines the methods provided by a [`CosmosClient`]
21+
///
22+
/// This trait is intended to allow you to mock out the `CosmosClient` when testing your application.
23+
/// Rather than depending on `CosmosClient`, you can depend on a generic parameter constrained by this trait, or an `impl CosmosClientMethods` type.
2024
pub trait CosmosClientMethods {
25+
/// Gets a [`DatabaseClient`] that can be used to access the database with the specified ID.
2126
fn database(&self, name: impl Into<String>) -> DatabaseClient;
2227
}
2328

2429
impl CosmosClient {
25-
/// Creates a new CosmosClient from the specified [TokenCredential] and [CosmosClientOptions].
30+
/// Creates a new CosmosClient, using Entra ID authentication.
2631
pub fn new(
2732
endpoint: impl AsRef<str>,
2833
credential: Arc<dyn TokenCredential>,
@@ -39,6 +44,7 @@ impl CosmosClient {
3944
})
4045
}
4146

47+
/// Creates a new CosmosClient, using shared key authentication.
4248
#[cfg(feature = "key-auth")]
4349
pub fn with_shared_key(
4450
endpoint: impl AsRef<str>,
@@ -56,12 +62,14 @@ impl CosmosClient {
5662
})
5763
}
5864

65+
/// Gets the endpoint of the database account this client is connected to.
5966
pub fn endpoint(&self) -> &Url {
6067
&self.endpoint
6168
}
6269
}
6370

6471
impl CosmosClientMethods for CosmosClient {
72+
/// Gets a [`DatabaseClient`] that can be used to access the database with the specified ID.
6573
fn database(&self, id: impl Into<String>) -> DatabaseClient {
6674
DatabaseClient::new(self.clone(), id.into())
6775
}

sdk/cosmosdb/azure_data_cosmos/src/clients/database_client.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ use azure_core::{Context, Request};
55
use url::Url;
66

77
pub trait DatabaseClientMethods {
8-
fn read(
8+
async fn read(
99
&self,
1010
options: Option<ReadDatabaseOptions>,
11-
) -> impl std::future::Future<
12-
Output = azure_core::Result<azure_core::Response<DatabaseProperties>>,
13-
> + Send;
11+
) -> azure_core::Result<azure_core::Response<DatabaseProperties>>;
1412
}
1513

1614
pub struct DatabaseClient {
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
mod database_client;
21
mod cosmos_client;
2+
mod database_client;
33

4-
pub use database_client::{DatabaseClient, DatabaseClientMethods};
54
pub use cosmos_client::{CosmosClient, CosmosClientMethods};
5+
pub use database_client::{DatabaseClient, DatabaseClientMethods};

sdk/cosmosdb/azure_data_cosmos/src/options/mod.rs

+4-21
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use azure_core::ClientOptions;
22

33
#[derive(Clone, Debug, Default)]
44
pub struct CosmosClientOptions {
5-
pub(crate) client_options: ClientOptions
5+
pub(crate) client_options: ClientOptions,
66
}
77

88
impl CosmosClientOptions {
@@ -12,19 +12,12 @@ impl CosmosClientOptions {
1212
}
1313

1414
#[derive(Clone, Debug, Default)]
15-
pub struct ReadDatabaseOptions {
16-
pub(crate) if_match: Option<azure_core::Etag>,
17-
pub(crate) if_none_match: Option<azure_core::Etag>,
18-
}
15+
pub struct ReadDatabaseOptions {}
1916

20-
impl ReadDatabaseOptions {
21-
pub fn builder() -> builders::ReadDatabaseOptionsBuilder {
22-
builders::ReadDatabaseOptionsBuilder::default()
23-
}
24-
}
17+
impl ReadDatabaseOptions {}
2518

2619
pub mod builders {
27-
use crate::{ReadDatabaseOptions, CosmosClientOptions};
20+
use crate::{CosmosClientOptions, ReadDatabaseOptions};
2821

2922
#[derive(Default)]
3023
pub struct CosmosClientOptionsBuilder(CosmosClientOptions);
@@ -42,15 +35,5 @@ pub mod builders {
4235
pub fn build(&self) -> ReadDatabaseOptions {
4336
self.0.clone()
4437
}
45-
46-
pub fn if_match(&mut self, if_match: azure_core::Etag) -> &mut Self {
47-
self.0.if_match = Some(if_match);
48-
self
49-
}
50-
51-
pub fn if_none_match(&mut self, if_none_match: azure_core::Etag) -> &mut Self {
52-
self.0.if_none_match = Some(if_none_match);
53-
self
54-
}
5538
}
5639
}

0 commit comments

Comments
 (0)