Skip to content

Commit a3edad5

Browse files
committed
Remove AuthenticationManager::from_custom_service_account() in favor of documentation
1 parent 232c313 commit a3edad5

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/authentication_manager.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,16 @@ pub(crate) trait ServiceAccount: Send + Sync {
1717

1818
/// Authentication manager is responsible for caching and obtaing credentials for the required scope
1919
///
20-
/// Cacheing for the full life time is ensured
20+
/// Construct the authentication manager with [`AuthenticationManager::new()`] or by creating
21+
/// a [`CustomServiceAccount`], then converting it into an `AuthenticationManager` using the `From`
22+
/// impl.
2123
pub struct AuthenticationManager {
2224
pub(crate) client: HyperClient,
2325
pub(crate) service_account: Box<dyn ServiceAccount>,
2426
refresh_mutex: Mutex<()>,
2527
}
2628

2729
impl AuthenticationManager {
28-
/// Create an `AuthenticationManager` directly from a custom service account
29-
pub fn from_custom_service_account(service_account: CustomServiceAccount) -> Self {
30-
Self::build(types::client(), service_account)
31-
}
32-
3330
/// Finds a service account provider to get authentication tokens from
3431
///
3532
/// Tries the following approaches, in order:
@@ -46,7 +43,7 @@ impl AuthenticationManager {
4643
pub async fn new() -> Result<Self, Error> {
4744
tracing::debug!("Initializing gcp_auth");
4845
if let Some(service_account) = CustomServiceAccount::from_env()? {
49-
return Ok(Self::from_custom_service_account(service_account));
46+
return Ok(service_account.into());
5047
}
5148

5249
let client = types::client();
@@ -121,6 +118,6 @@ impl AuthenticationManager {
121118

122119
impl From<CustomServiceAccount> for AuthenticationManager {
123120
fn from(service_account: CustomServiceAccount) -> Self {
124-
Self::from_custom_service_account(service_account)
121+
Self::build(types::client(), service_account)
125122
}
126123
}

src/custom_service_account.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ use crate::types::{HyperClient, Signer, Token};
1111
use crate::util::HyperExt;
1212

1313
/// A custom service account containing credentials
14+
///
15+
/// Once initialized, a [`CustomServiceAccount`] can be converted into an [`AuthenticationManager`]
16+
/// using the applicable `From` implementation.
1417
#[derive(Debug)]
1518
pub struct CustomServiceAccount {
1619
credentials: ApplicationCredentials,

0 commit comments

Comments
 (0)