pub struct BasicAuth { /* private fields */ }
Expand description
HTTP Basic authorization.
§Specifications
§Examples
use http_types_rs::Response;
use http_types_rs::auth::{AuthenticationScheme, BasicAuth};
let username = "nori";
let password = "secret_fish!!";
let authz = BasicAuth::new(username, password);
let mut res = Response::new(200);
res.insert_header(&authz, &authz);
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 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.
Trait Implementations§
Source§impl Header for BasicAuth
impl Header for BasicAuth
Source§fn header_name(&self) -> HeaderName
fn header_name(&self) -> HeaderName
Access the header’s name.
Source§fn header_value(&self) -> HeaderValue
fn header_value(&self) -> HeaderValue
Access the header’s value.
Auto Trait Implementations§
impl Freeze for BasicAuth
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
Source§impl<T> ToHeaderValues for Twhere
T: Header,
impl<T> ToHeaderValues for Twhere
T: Header,
Source§type Iter = IntoIter<HeaderValue>
type Iter = IntoIter<HeaderValue>
Returned iterator over header values which this type may correspond to.
Source§fn to_header_values(&self) -> Result<<T as ToHeaderValues>::Iter, Error>
fn to_header_values(&self) -> Result<<T as ToHeaderValues>::Iter, Error>
Converts this object to an iterator of resolved
HeaderValues
.