#[non_exhaustive]pub struct CosmosAccountReference { /* private fields */ }Expand description
A reference to a Cosmos DB account, combining an endpoint with a credential.
This type bundles together the account endpoint and the credential needed to
authenticate with it. Use convenience constructors with_credential()
or with_master_key() to create instances.
§Examples
Using Entra ID authentication:
use azure_data_cosmos::{CosmosAccountReference, CosmosAccountEndpoint};
use std::sync::Arc;
let credential: Arc<dyn azure_core::credentials::TokenCredential> =
azure_identity::DeveloperToolsCredential::new(None).unwrap();
let endpoint: CosmosAccountEndpoint = "https://myaccount.documents.azure.com/".parse().unwrap();
let account = CosmosAccountReference::with_credential(endpoint, credential);Using key authentication (requires key_auth feature):
ⓘ
use azure_data_cosmos::{CosmosAccountReference, CosmosAccountEndpoint};
use azure_core::credentials::Secret;
let endpoint: CosmosAccountEndpoint = "https://myaccount.documents.azure.com/".parse().unwrap();
let account = CosmosAccountReference::with_master_key(endpoint, Secret::from("my_account_key"));Implementations§
Source§impl CosmosAccountReference
impl CosmosAccountReference
Sourcepub fn with_credential(
endpoint: CosmosAccountEndpoint,
credential: Arc<dyn TokenCredential>,
) -> Self
pub fn with_credential( endpoint: CosmosAccountEndpoint, credential: Arc<dyn TokenCredential>, ) -> Self
Creates a new account reference with an Entra ID (Azure AD) token credential.
§Arguments
endpoint- The Cosmos DB account endpoint.credential- An Entra ID token credential.
Sourcepub fn with_master_key(endpoint: CosmosAccountEndpoint, key: Secret) -> Self
Available on crate feature key_auth only.
pub fn with_master_key(endpoint: CosmosAccountEndpoint, key: Secret) -> Self
key_auth only.Creates a new account reference with a master key.
§Arguments
endpoint- The Cosmos DB account endpoint.key- The primary or secondary account key.
Trait Implementations§
Source§impl Clone for CosmosAccountReference
impl Clone for CosmosAccountReference
Source§fn clone(&self) -> CosmosAccountReference
fn clone(&self) -> CosmosAccountReference
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CosmosAccountReference
impl Debug for CosmosAccountReference
Source§impl<C: Into<CosmosCredential>> From<(CosmosAccountEndpoint, C)> for CosmosAccountReference
impl<C: Into<CosmosCredential>> From<(CosmosAccountEndpoint, C)> for CosmosAccountReference
Source§fn from((endpoint, credential): (CosmosAccountEndpoint, C)) -> Self
fn from((endpoint, credential): (CosmosAccountEndpoint, C)) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for CosmosAccountReference
impl !RefUnwindSafe for CosmosAccountReference
impl Send for CosmosAccountReference
impl Sync for CosmosAccountReference
impl Unpin for CosmosAccountReference
impl UnsafeUnpin for CosmosAccountReference
impl !UnwindSafe for CosmosAccountReference
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more