pub struct FnCredentials { /* private fields */ }Expand description
A CredentialSource backed by an async closure, e.g. a keychain lookup.
use graphrt_llm::credentials::{Credential, FnCredentials};
let source = FnCredentials::new(|provider: String| async move {
// Read the user's own key for `provider` from secure storage here.
Ok(Credential::new(format!("key-for-{provider}")))
});Implementations§
Source§impl FnCredentials
impl FnCredentials
Trait Implementations§
Source§impl Clone for FnCredentials
impl Clone for FnCredentials
Source§impl CredentialSource for FnCredentials
impl CredentialSource for FnCredentials
Source§fn credential<'a>(
&'a self,
provider: &'a str,
) -> BoxFuture<'a, Result<Credential, LlmError>>
fn credential<'a>( &'a self, provider: &'a str, ) -> BoxFuture<'a, Result<Credential, LlmError>>
Credential for
provider (the registry name, e.g. openai).Source§fn invalidate(&self, provider: &str)
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
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.Auto Trait Implementations§
impl !RefUnwindSafe for FnCredentials
impl !UnwindSafe for FnCredentials
impl Forget for FnCredentials
impl Freeze for FnCredentials
impl Move for FnCredentials
impl Send for FnCredentials
impl Sync for FnCredentials
impl Unpin for FnCredentials
impl UnsafeUnpin for FnCredentials
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