pub enum Auth {
Bearer {
token: TokenSource,
},
Basic {
username: TokenSource,
password: TokenSource,
},
Custom {
prefix: String,
value: TokenSource,
},
}Expand description
Authentication configuration for a client or request.
Variants§
Bearer
Authorization: Bearer …
Fields
§
token: TokenSourceToken source.
Basic
Authorization: Basic …
Custom
Authorization: {prefix} {value}
Fields
§
value: TokenSourceCredential value source.
Implementations§
Source§impl Auth
impl Auth
Sourcepub fn bearer_fn(f: impl Fn() -> Option<String> + Send + Sync + 'static) -> Auth
pub fn bearer_fn(f: impl Fn() -> Option<String> + Send + Sync + 'static) -> Auth
Bearer token from a closure (e.g. read from a cache).
§Examples
use better_fetch::Auth;
let auth = Auth::bearer_fn(|| Some("cached-token".into()));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