Struct ajars_surf::surf::http::auth::Authorization
[−]pub struct Authorization { /* private fields */ }
Expand description
Credentials to authenticate a user agent with a server.
Specifications
Examples
use http_types::Response;
use http_types::auth::{AuthenticationScheme, Authorization};
let scheme = AuthenticationScheme::Basic;
let credentials = "0xdeadbeef202020";
let authz = Authorization::new(scheme, credentials.into());
let mut res = Response::new(200);
authz.apply(&mut res);
let authz = Authorization::from_headers(res)?.unwrap();
assert_eq!(authz.scheme(), AuthenticationScheme::Basic);
assert_eq!(authz.credentials(), credentials);
Implementations
impl Authorization
impl Authorization
pub fn new(scheme: AuthenticationScheme, credentials: String) -> Authorization
pub fn new(scheme: AuthenticationScheme, credentials: String) -> Authorization
Create a new instance of Authorization
.
pub fn from_headers(
headers: impl AsRef<Headers>
) -> Result<Option<Authorization>, Error>
pub fn from_headers(
headers: impl AsRef<Headers>
) -> Result<Option<Authorization>, Error>
Create a new instance from headers.
pub fn name(&self) -> HeaderName
pub fn name(&self) -> HeaderName
Get the HeaderName
.
pub fn value(&self) -> HeaderValue
pub fn value(&self) -> HeaderValue
Get the HeaderValue
.
pub fn scheme(&self) -> AuthenticationScheme
pub fn scheme(&self) -> AuthenticationScheme
Get the authorization scheme.
pub fn set_scheme(&mut self, scheme: AuthenticationScheme)
pub fn set_scheme(&mut self, scheme: AuthenticationScheme)
Set the authorization scheme.
pub fn credentials(&self) -> &str
pub fn credentials(&self) -> &str
Get the authorization credentials.
pub fn set_credentials(&mut self, credentials: String)
pub fn set_credentials(&mut self, credentials: String)
Set the authorization credentials.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Authorization
impl Send for Authorization
impl Sync for Authorization
impl Unpin for Authorization
impl UnwindSafe for Authorization
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