pub trait CredentialSource: Send + Sync {
// Required method
fn api_key(
&self,
provider_id: &str,
config: &ProviderConfig,
) -> Result<Secret, String>;
}Expand description
Where a provider’s credential comes from.
Synchronous, and that is a real constraint: a source that has to reach a network vault must resolve eagerly and cache, because this is called while provider configuration is being turned into live clients, at startup. The dynamic case — a token that expires mid-session and must be refreshed per-request — is not this trait’s job; that is what a bearer-token provider is for, and one can be handed out here inside whatever the factory builds.
Required Methods§
Sourcefn api_key(
&self,
provider_id: &str,
config: &ProviderConfig,
) -> Result<Secret, String>
fn api_key( &self, provider_id: &str, config: &ProviderConfig, ) -> Result<Secret, String>
The API key for provider_id, or a reason there is none.
The reason is phrased without naming the provider — the caller knows which provider it asked about and prefixes it, so the message reads the same wherever it surfaces.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".