Struct Policy
struct Policy { ... }
A type that controls the policy on how to handle the following of redirects.
The default value will catch redirect loops, and has a maximum of 10 redirects it will follow in a chain before returning an error.
limitedcan be used have the same as the default behavior, but adjust the allowed maximum redirect hops in a chain.nonecan be used to disable all redirect behavior.customcan be used to create a customized policy.
Implementations
impl Policy
fn limited(max: usize) -> SelfCreate a
Policywith a maximum number of redirects.An
Errorwill be returned if the max is reached.fn none() -> SelfCreate a
Policythat does not follow any redirect.fn custom<T>(policy: T) -> Self where T: Fn(Attempt<'_>) -> Action + Send + Sync + 'staticCreate a custom
Policyusing the passed function.Note
The default
Policyhandles a maximum loop chain, but the custom variant does not do that for you automatically. The custom policy should have some way of handling those.Information on the next request and previous requests can be found on the
Attemptargument passed to the closure.Actions can be conveniently created from methods on the
Attempt.Example
# use ; # #fn redirect(self: &Self, attempt: Attempt<'_>) -> ActionApply this policy to a given
Attemptto produce aAction.Note
This method can be used together with
Policy::custom()to construct onePolicythat wraps another.Example
# use ; # #
impl Debug for Policy
fn fmt(self: &Self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl Default for Policy
fn default() -> Policy
impl Freeze for Policy
impl RefUnwindSafe for Policy
impl Send for Policy
impl Sync for Policy
impl Unpin for Policy
impl UnwindSafe for Policy
impl<T> Any for Policy
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Policy
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Policy
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> ErasedDestructor for Policy
impl<T> From for Policy
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Instrument for Policy
impl<T> PolicyExt for Policy
fn and<P, B, E>(self: Self, other: P) -> And<T, P> where T: Policy<B, E>, P: Policy<B, E>fn or<P, B, E>(self: Self, other: P) -> Or<T, P> where T: Policy<B, E>, P: Policy<B, E>
impl<T> WithSubscriber for Policy
impl<T, U> Into for Policy
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Policy
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Policy
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>