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
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§
Source§impl Debug for Credentials
impl Debug for Credentials
Source§impl FromStr for Credentials
impl FromStr for Credentials
Source§fn 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.
Source§type Err = AuthBasicError
type Err = AuthBasicError
The associated error which can be returned from parsing.
Source§impl PartialEq for Credentials
impl PartialEq for Credentials
impl StructuralPartialEq for Credentials
Auto Trait Implementations§
impl Freeze for Credentials
impl RefUnwindSafe for Credentials
impl Send for Credentials
impl Sync for Credentials
impl Unpin for Credentials
impl UnwindSafe for Credentials
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