Skip to main content

KeyAuth

Trait KeyAuth 

Source
pub trait KeyAuth: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn has_login(&self) -> bool;
    fn login<'a>(
        &'a self,
        interaction: &'a Interaction,
    ) -> BoxFuture<'a, Result<ApiKeyCredential, AuthError>>;
    fn resolve<'a>(
        &'a self,
        credential: Option<&'a ApiKeyCredential>,
    ) -> BoxFuture<'a, Result<Option<Resolved>, String>>;
}
Expand description

pi-ai’s ApiKeyAuth of a provider an extension implements.

Required Methods§

Source

fn name(&self) -> &str

The method’s name, such as “Anthropic API key”.

Source

fn has_login(&self) -> bool

Whether KeyAuth::login asks for the credential. Without it the key is set up outside yapi.

Source

fn login<'a>( &'a self, interaction: &'a Interaction, ) -> BoxFuture<'a, Result<ApiKeyCredential, AuthError>>

Asks for the credential to store through interaction.

Source

fn resolve<'a>( &'a self, credential: Option<&'a ApiKeyCredential>, ) -> BoxFuture<'a, Result<Option<Resolved>, String>>

Request credentials from credential, whose key is resolved, else from the environment, or None when the provider is not configured.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§