#[non_exhaustive]pub struct Attempt<'a, const PENDING: bool = true> {
pub status: StatusCode,
pub headers: Cow<'a, HeaderMap>,
pub uri: Cow<'a, Uri>,
pub previous: Cow<'a, [Uri]>,
}Expand description
A type that holds information on the next request and previous requests in redirect chain.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.status: StatusCodeThe status code of the redirect response.
headers: Cow<'a, HeaderMap>The headers of the redirect response.
uri: Cow<'a, Uri>The URI to redirect to.
previous: Cow<'a, [Uri]>The list of previous URIs that have already been requested in this chain.
Implementations§
Source§impl<const PENDING: bool> Attempt<'_, PENDING>
impl<const PENDING: bool> Attempt<'_, PENDING>
Source§impl Attempt<'_, true>
impl Attempt<'_, true>
Sourcepub fn pending<F, Fut>(self, func: F) -> Action
pub fn pending<F, Fut>(self, func: F) -> Action
Returns an action meaning wreq should perform the redirect asynchronously.
The provided async closure receives an owned Attempt<'static> and should
return an Action to determine the final redirect behavior.
§Example
let policy = redirect::Policy::custom(|attempt| {
attempt.pending(|attempt| async move {
// Perform some async operation
if attempt.uri().host() == Some("trusted.domain") {
attempt.follow()
} else {
attempt.stop()
}
})
});Trait Implementations§
Auto Trait Implementations§
impl<'a, const PENDING: bool = true> !Freeze for Attempt<'a, PENDING>
impl<'a, const PENDING: bool> Forget for Attempt<'a, PENDING>
impl<'a, const PENDING: bool> Move for Attempt<'a, PENDING>
impl<'a, const PENDING: bool> RefUnwindSafe for Attempt<'a, PENDING>
impl<'a, const PENDING: bool> Send for Attempt<'a, PENDING>
impl<'a, const PENDING: bool> Sync for Attempt<'a, PENDING>
impl<'a, const PENDING: bool> Unpin for Attempt<'a, PENDING>
impl<'a, const PENDING: bool> UnsafeUnpin for Attempt<'a, PENDING>
impl<'a, const PENDING: bool> UnwindSafe for Attempt<'a, PENDING>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more