Skip to main content

CredentialSource

Trait CredentialSource 

Source
pub trait CredentialSource:
    Send
    + Sync
    + Debug {
    // Required method
    fn credential<'a>(
        &'a self,
        provider: &'a str,
    ) -> BoxFuture<'a, Result<Credential, LlmError>>;

    // Provided methods
    fn invalidate(&self, provider: &str) { ... }
    fn generation(&self) -> u64 { ... }
}
Expand description

Supplies credentials on demand.

Required Methods§

Source

fn credential<'a>( &'a self, provider: &'a str, ) -> BoxFuture<'a, Result<Credential, LlmError>>

Credential for provider (the registry name, e.g. openai).

Provided Methods§

Source

fn invalidate(&self, provider: &str)

Called when the provider rejected the last credential (HTTP 401/403), so cached values can be dropped before one retry.

Source

fn generation(&self) -> u64

A counter that changes whenever credentials this source would return for any provider may have changed outside of CredentialSource::invalidate (e.g. the host app signed a user out or registered a new key source). CachedCredentials drops cached values when it changes. Default: never changes.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<S: CredentialSource + ?Sized> CredentialSource for Arc<S>

Source§

fn credential<'a>( &'a self, provider: &'a str, ) -> BoxFuture<'a, Result<Credential, LlmError>>

Source§

fn invalidate(&self, provider: &str)

Source§

fn generation(&self) -> u64

Implementors§