Trait reqwest_wasm_ext::ReqwestExt
source · [−]pub trait ReqwestExt: Sized {
fn basic_auth<U, P>(self, username: U, password: Option<P>) -> Self
where
U: Display,
P: Display;
fn basic_auth_ext<U, P>(self, username: U, password: Option<P>) -> Self
where
U: Display,
P: Display,
{ ... }
}
Expand description
Allow using basic_auth
on both wasm and non-wasm targets
Required methods
fn basic_auth<U, P>(self, username: U, password: Option<P>) -> Self where
U: Display,
P: Display,
fn basic_auth<U, P>(self, username: U, password: Option<P>) -> Self where
U: Display,
P: Display,
Drop in replacement for reqwest::RequestBuilder::basic_auth
.
This is a drop in replacement. However, it requires that the trait is in the context. In the case of a non-wasm target, the function is present, the trait unused and a warning will be issued.
To fix this warning, you can either:
- Restrict the trait import using
#[cfg(target_arch = "wasm32")]
- Use the [
basic_auth_ext
] function
On non-wasm32 targets, the function directly calls reqwest::RequestBuilder::basic_auth
.