[][src]Struct http_types::auth::BasicAuth

pub struct BasicAuth { /* fields omitted */ }

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

impl BasicAuth[src]

pub fn new<U, P>(username: U, password: P) -> Self where
    U: AsRef<str>,
    P: AsRef<str>, 
[src]

Create a new instance of BasicAuth.

pub fn from_headers(headers: impl AsRef<Headers>) -> Result<Option<Self>>[src]

Create a new instance from headers.

pub fn from_credentials(credentials: impl AsRef<[u8]>) -> Result<Self>[src]

Create a new instance from the base64 encoded credentials.

pub fn apply(&self, headers: impl AsMut<Headers>)[src]

Sets the header.

pub fn name(&self) -> HeaderName[src]

Get the HeaderName.

pub fn value(&self) -> HeaderValue[src]

Get the HeaderValue.

pub fn username(&self) -> &str[src]

Get the username.

pub fn password(&self) -> &str[src]

Get the password.

Trait Implementations

impl Debug for BasicAuth[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,