pub struct ApiKeyProvider { /* private fields */ }Expand description
Static API-key provider. The header name is configurable so this works
for both Anthropic (x-api-key) and any other vendor that uses a
non-Authorization header.
Implementations§
Source§impl ApiKeyProvider
impl ApiKeyProvider
Sourcepub fn new(header_name: &str, api_key: impl Into<SecretString>) -> Result<Self>
pub fn new(header_name: &str, api_key: impl Into<SecretString>) -> Result<Self>
Construct from a header name and a raw key string.
Returns Error::Config if header_name cannot be parsed as a valid
HTTP header name.
Sourcepub fn anthropic(api_key: impl Into<SecretString>) -> Self
pub fn anthropic(api_key: impl Into<SecretString>) -> Self
Convenience: Anthropic-style x-api-key provider.
Trait Implementations§
Source§impl CredentialProvider for ApiKeyProvider
impl CredentialProvider for ApiKeyProvider
Source§fn resolve<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Credentials>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn resolve<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Credentials>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Resolve current credentials. Long-running impls should respect
tokio cancellation in their internals; the transport supplies the
ExecutionContext indirectly via the surrounding async task.Auto Trait Implementations§
impl !Freeze for ApiKeyProvider
impl RefUnwindSafe for ApiKeyProvider
impl Send for ApiKeyProvider
impl Sync for ApiKeyProvider
impl Unpin for ApiKeyProvider
impl UnsafeUnpin for ApiKeyProvider
impl UnwindSafe for ApiKeyProvider
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