Struct http_types::auth::BasicAuth
source · pub struct BasicAuth { /* private fields */ }
Expand description
HTTP Basic authorization.
Specifications
Examples
use http_types::Response;
use http_types::auth::{AuthenticationScheme, BasicAuth};
let username = "nori";
let password = "secret_fish!!";
let authz = BasicAuth::new(username, password);
let mut res = Response::new(200);
authz.apply(&mut res);
let authz = BasicAuth::from_headers(res)?.unwrap();
assert_eq!(authz.username(), username);
assert_eq!(authz.password(), password);
Implementations§
source§impl BasicAuth
impl BasicAuth
sourcepub fn new<U, P>(username: U, password: P) -> Selfwhere
U: AsRef<str>,
P: AsRef<str>,
pub fn new<U, P>(username: U, password: P) -> Selfwhere U: AsRef<str>, P: AsRef<str>,
Create a new instance of BasicAuth
.
sourcepub fn from_headers(headers: impl AsRef<Headers>) -> Result<Option<Self>>
pub fn from_headers(headers: impl AsRef<Headers>) -> Result<Option<Self>>
Create a new instance from headers.
sourcepub fn from_credentials(credentials: impl AsRef<[u8]>) -> Result<Self>
pub fn from_credentials(credentials: impl AsRef<[u8]>) -> Result<Self>
Create a new instance from the base64 encoded credentials.
sourcepub fn name(&self) -> HeaderName
pub fn name(&self) -> HeaderName
Get the HeaderName
.
sourcepub fn value(&self) -> HeaderValue
pub fn value(&self) -> HeaderValue
Get the HeaderValue
.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for BasicAuth
impl Send for BasicAuth
impl Sync for BasicAuth
impl Unpin for BasicAuth
impl UnwindSafe for BasicAuth
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