pub struct WwwAuthenticate { /* private fields */ }
Expand description
Define the authentication method that should be used to gain access to a resource.
§Specifications
§Implementation Notes
This implementation only encodes and parses a single authentication method, further authorization methods are ignored. It also always passes the utf-8 encoding flag.
§Examples
use http_types_rs::Response;
use http_types_rs::auth::{AuthenticationScheme, WwwAuthenticate};
let scheme = AuthenticationScheme::Basic;
let realm = "Access to the staging site";
let authz = WwwAuthenticate::new(scheme, realm.into());
let mut res = Response::new(200);
res.insert_header(&authz, &authz);
let authz = WwwAuthenticate::from_headers(res)?.unwrap();
assert_eq!(authz.scheme(), AuthenticationScheme::Basic);
assert_eq!(authz.realm(), realm);
Implementations§
Source§impl WwwAuthenticate
impl WwwAuthenticate
Sourcepub fn new(scheme: AuthenticationScheme, realm: String) -> Self
pub fn new(scheme: AuthenticationScheme, realm: String) -> Self
Create a new instance of WwwAuthenticate
.
Sourcepub fn from_headers(headers: impl AsRef<Headers>) -> Result<Option<Self>>
pub fn from_headers(headers: impl AsRef<Headers>) -> Result<Option<Self>>
Create a new instance from headers.
Sourcepub fn scheme(&self) -> AuthenticationScheme
pub fn scheme(&self) -> AuthenticationScheme
Get the authorization scheme.
Sourcepub fn set_scheme(&mut self, scheme: AuthenticationScheme)
pub fn set_scheme(&mut self, scheme: AuthenticationScheme)
Set the authorization scheme.
Trait Implementations§
Source§impl Debug for WwwAuthenticate
impl Debug for WwwAuthenticate
Source§impl Header for WwwAuthenticate
impl Header for WwwAuthenticate
Source§fn header_name(&self) -> HeaderName
fn header_name(&self) -> HeaderName
Access the header’s name.
Source§fn header_value(&self) -> HeaderValue
fn header_value(&self) -> HeaderValue
Access the header’s value.
Auto Trait Implementations§
impl Freeze for WwwAuthenticate
impl RefUnwindSafe for WwwAuthenticate
impl Send for WwwAuthenticate
impl Sync for WwwAuthenticate
impl Unpin for WwwAuthenticate
impl UnwindSafe for WwwAuthenticate
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
Source§impl<T> ToHeaderValues for Twhere
T: Header,
impl<T> ToHeaderValues for Twhere
T: Header,
Source§type Iter = IntoIter<HeaderValue>
type Iter = IntoIter<HeaderValue>
Returned iterator over header values which this type may correspond to.
Source§fn to_header_values(&self) -> Result<<T as ToHeaderValues>::Iter, Error>
fn to_header_values(&self) -> Result<<T as ToHeaderValues>::Iter, Error>
Converts this object to an iterator of resolved
HeaderValues
.