pub enum AuthorizationHeader {
Basic {
username: String,
password: String,
},
Bearer {
token: String,
},
}Expand description
Variants§
Implementations§
Source§impl AuthorizationHeader
impl AuthorizationHeader
Sourcepub fn basic(username: impl Into<String>, password: impl Into<String>) -> Self
pub fn basic(username: impl Into<String>, password: impl Into<String>) -> Self
Constructor for basic authorization header
Sourcepub fn header_value(&self) -> Result<HeaderValue, InvalidHeaderValue>
pub fn header_value(&self) -> Result<HeaderValue, InvalidHeaderValue>
generate a HeaderValue
let header = AuthorizationHeader::basic("aladdin", "opensesame");
assert_eq!(
http::HeaderValue::from_str("Basic YWxhZGRpbjpvcGVuc2VzYW1l").unwrap(),
header.header_value().unwrap()
);Trait Implementations§
Source§impl Debug for AuthorizationHeader
impl Debug for AuthorizationHeader
Source§impl TryFrom<&AuthorizationHeader> for HeaderMap
impl TryFrom<&AuthorizationHeader> for HeaderMap
Source§type Error = ParseError
type Error = ParseError
The type returned in the event of a conversion error.
Source§impl TryFrom<&HeaderMap> for AuthorizationHeader
impl TryFrom<&HeaderMap> for AuthorizationHeader
Source§impl TryFrom<AuthorizationHeader> for HeaderMap
impl TryFrom<AuthorizationHeader> for HeaderMap
Source§type Error = ParseError
type Error = ParseError
The type returned in the event of a conversion error.
Auto Trait Implementations§
impl Freeze for AuthorizationHeader
impl RefUnwindSafe for AuthorizationHeader
impl Send for AuthorizationHeader
impl Sync for AuthorizationHeader
impl Unpin for AuthorizationHeader
impl UnwindSafe for AuthorizationHeader
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