http_auth

Struct PasswordClientBuilder

source
pub struct PasswordClientBuilder(/* private fields */);
Expand description

Builds a PasswordClient from the supplied challenges; create via PasswordClient::builder.

Often you can just use PasswordClient’s TryFrom implementations to convert from a parsed challenge (crate::ChallengeRef) or unparsed challenges (str, [http::header::HeaderValue], or [http::header::GetAll]).

The builder allows more flexibility. For example, if you are using a HTTP library which is not based on a http crate, you might need to create a PasswordClient from an iterator over multiple WWW-Authenticate headers. You can feed each to PasswordClientBuilder::challenges.

Prefers Digest over Basic, consistent with the RFC 7235 section 2.1 advice for a user-agent to pick the most secure auth-scheme it understands.

When there are multiple Digest challenges, currently uses the first, consistent with the RFC 7616 section 3.7 advice to “use the first challenge it supports, unless a local policy dictates otherwise”. In the future, it may prioritize by algorithm.

Ignores parse errors as long as there’s at least one parseable, supported challenge.

§Example

Implementations§

source§

impl PasswordClientBuilder

source

pub fn challenges(self, value: &str) -> Self

Considers all challenges from the given &str challenge list.

source

pub fn challenge(self, challenge: &ChallengeRef<'_>) -> Self

Considers a single challenge.

source

pub fn build(self) -> Result<PasswordClient, String>

Returns a new PasswordClient or fails.

Trait Implementations§

source§

impl Default for PasswordClientBuilder

source§

fn default() -> PasswordClientBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.