Struct http_auth_basic::Credentials
source · [−]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
sourceimpl Credentials
impl Credentials
sourcepub fn new(user_id: &str, password: &str) -> Self
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"),
};
sourcepub fn decode(auth_header_value: String) -> Result<Self, AuthBasicError>
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
sourcepub fn from_header(auth_header: String) -> Result<Credentials, AuthBasicError>
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.
sourcepub fn as_http_header(&self) -> String
pub fn as_http_header(&self) -> String
Creates a HTTP Authorization header value for the basic schema
from the Credentials
instance
Trait Implementations
sourceimpl Debug for Credentials
impl Debug for Credentials
sourceimpl FromStr for Credentials
impl FromStr for Credentials
sourcefn from_str(s: &str) -> Result<Self, Self::Err>
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.
type Err = AuthBasicError
type Err = AuthBasicError
The associated error which can be returned from parsing.
sourceimpl PartialEq<Credentials> for Credentials
impl PartialEq<Credentials> for Credentials
sourcefn eq(&self, other: &Credentials) -> bool
fn eq(&self, other: &Credentials) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &Credentials) -> bool
fn ne(&self, other: &Credentials) -> bool
This method tests for !=
.
impl StructuralPartialEq for Credentials
Auto Trait Implementations
impl RefUnwindSafe for Credentials
impl Send for Credentials
impl Sync for Credentials
impl Unpin for Credentials
impl UnwindSafe for Credentials
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more