#[non_exhaustive]pub enum Auth {
Bearer(SecretString),
Basic {
username: String,
password: SecretString,
},
ApiKey {
name: String,
value: SecretString,
},
None,
}Expand description
Authentication method for HTTP requests.
Secret-bearing variants redact their values in Debug
output while preserving the plaintext for request header application.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Bearer(SecretString)
Bearer token authentication: Authorization: Bearer <token>
Basic
HTTP Basic authentication: Authorization: Basic <base64(username:password)>
Fields
§
password: SecretStringPassword for basic authentication
ApiKey
API key authentication: custom header with key value
None
No authentication.
Implementations§
Source§impl Auth
impl Auth
Sourcepub fn bearer_secret(token: SecretString) -> Self
pub fn bearer_secret(token: SecretString) -> Self
Creates a Bearer token auth from a redacting secret.
Sourcepub fn basic(username: impl Into<String>, password: impl Into<String>) -> Self
pub fn basic(username: impl Into<String>, password: impl Into<String>) -> Self
Creates a Basic auth from a plaintext password.
Sourcepub fn basic_secret(username: impl Into<String>, password: SecretString) -> Self
pub fn basic_secret(username: impl Into<String>, password: SecretString) -> Self
Creates a Basic auth from a redacting password secret.
Sourcepub fn api_key(name: impl Into<String>, value: impl Into<String>) -> Self
pub fn api_key(name: impl Into<String>, value: impl Into<String>) -> Self
Creates an API key auth with custom header name and plaintext value.
Sourcepub fn api_key_secret(name: impl Into<String>, value: SecretString) -> Self
pub fn api_key_secret(name: impl Into<String>, value: SecretString) -> Self
Creates an API key auth with a custom header name and redacting secret value.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Auth
impl RefUnwindSafe for Auth
impl Send for Auth
impl Sync for Auth
impl Unpin for Auth
impl UnsafeUnpin for Auth
impl UnwindSafe for Auth
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