pub enum ApiKeySource {
Static(SecretString),
Dynamic(Arc<ApiKeyProvider>),
AsyncDynamic(Arc<AsyncApiKeyProvider>),
}Expand description
表示客户端使用的 API Key 来源。
Variants§
Static(SecretString)
使用固定字符串作为 API Key。
Dynamic(Arc<ApiKeyProvider>)
每次请求或重试时动态生成 API Key。
AsyncDynamic(Arc<AsyncApiKeyProvider>)
每次请求或重试时异步生成 API Key。
Implementations§
Source§impl ApiKeySource
impl ApiKeySource
Sourcepub fn from_static<T>(value: T) -> Self
pub fn from_static<T>(value: T) -> Self
创建一个静态 API Key 来源。
Sourcepub fn from_provider<F>(provider: F) -> Self
pub fn from_provider<F>(provider: F) -> Self
创建一个动态 API Key 来源。
Sourcepub fn from_async_provider<F, Fut>(provider: F) -> Self
pub fn from_async_provider<F, Fut>(provider: F) -> Self
创建一个异步 API Key 来源。
Sourcepub fn resolve(&self) -> Result<SecretString>
pub fn resolve(&self) -> Result<SecretString>
Sourcepub async fn resolve_async(&self) -> Result<SecretString>
pub async fn resolve_async(&self) -> Result<SecretString>
Trait Implementations§
Source§impl Clone for ApiKeySource
impl Clone for ApiKeySource
Source§fn clone(&self) -> ApiKeySource
fn clone(&self) -> ApiKeySource
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ApiKeySource
impl Debug for ApiKeySource
Source§impl From<SecretBox<str>> for ApiKeySource
impl From<SecretBox<str>> for ApiKeySource
Source§fn from(value: SecretString) -> Self
fn from(value: SecretString) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for ApiKeySource
impl !RefUnwindSafe for ApiKeySource
impl Send for ApiKeySource
impl Sync for ApiKeySource
impl Unpin for ApiKeySource
impl UnsafeUnpin for ApiKeySource
impl !UnwindSafe for ApiKeySource
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