pub struct HostCredentials { /* private fields */ }Expand description
Credential sources registered by the host at run time, per provider name
(* is the fallback for every provider). Cheap to clone; clones share state.
Registering, removing or clearing a source changes CredentialSource::generation,
so credentials cached from the previous source are dropped (sign-out takes
effect on the next request).
Implementations§
Source§impl HostCredentials
impl HostCredentials
pub fn new() -> Self
Sourcepub fn set(
&self,
provider: impl Into<String>,
source: Arc<dyn CredentialSource>,
)
pub fn set( &self, provider: impl Into<String>, source: Arc<dyn CredentialSource>, )
Register source for provider (or * for every provider), replacing any previous one.
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Drop every credential cached from host sources (e.g. after the user signed out of the app without the sources changing).
Trait Implementations§
Source§impl Clone for HostCredentials
impl Clone for HostCredentials
Source§impl CredentialSource for HostCredentials
impl CredentialSource for HostCredentials
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.Source§impl Debug for HostCredentials
impl Debug for HostCredentials
Auto Trait Implementations§
impl Forget for HostCredentials
impl Freeze for HostCredentials
impl Move for HostCredentials
impl RefUnwindSafe for HostCredentials
impl Send for HostCredentials
impl Sync for HostCredentials
impl Unpin for HostCredentials
impl UnsafeUnpin for HostCredentials
impl UnwindSafe for HostCredentials
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