Struct Credentials

Source
pub struct Credentials {
    pub user_id: String,
    pub password: String,
}
Expand description

A struct to represent the user_id and password fields from an Authorization Basic header value

Fields§

§user_id: String§password: String

Implementations§

Source§

impl Credentials

Source

pub fn new(user_id: &str, password: &str) -> Self

Create a new Credentials instance this is equivalent to writing:

use http_auth_basic::Credentials;

let credentials = Credentials {
    user_id: String::from("Foo"),
    password: String::from("Bar"),
};
Source

pub fn decode(auth_header_value: String) -> Result<Self, AuthBasicError>

Creates a Credentials instance from a base64 String which must encode user credentials as username:password

Source

pub fn encode(&self) -> String

Encode a Credentials instance into a base64 String

Source

pub fn from_header(auth_header: String) -> Result<Credentials, AuthBasicError>

Creates a Credentials instance from an HTTP Authorization header which schema is a valid Basic HTTP Authorization Schema.

Source

pub fn as_http_header(&self) -> String

Creates a HTTP Authorization header value for the basic schema from the Credentials instance

Trait Implementations§

Source§

impl Debug for Credentials

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromStr for Credentials

Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Creates a Credentials instance from either a base64 &str which must encode user credentials as username:password or an HTTP Authorization header which schema is a valid Basic HTTP Authorization Schema.

Source§

type Err = AuthBasicError

The associated error which can be returned from parsing.
Source§

impl PartialEq for Credentials

Source§

fn eq(&self, other: &Credentials) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Credentials

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.