Skip to main content

Refetch

Struct Refetch 

Source
pub struct Refetch<'f, 'r> { /* private fields */ }
Expand description

A fetch that starts again if its body fails in transit.

A body fails in transit in these cases:

  • the connection reports an error
  • the peer stays silent past the progress_timeout window
  • the transfer is slower than the low_speed rule allows.

Each refetch spends one repeat of max_retries, the count that also limits the rounds of the fetch. So the rounds of each fetch and the refetches between them share one budget. A refetch sends the request again, from the first destination. It sends the Range header of the request again, if the request has one, and adds no Range header of its own. So a refetch asks for the whole body again, or for the same part of it.

A body that fails in another way is not fetched again, because another fetch fails in the same way. Examples are the size cap and a failure of the consumer, such as a checksum mismatch.

Implementations§

Source§

impl Refetch<'_, '_>

Source

pub async fn fetch(&mut self) -> Result<Fetched>

Fetches the request, with the rest of the budget for its rounds.

§Errors

This method returns the errors that Fetcher::fetch returns.

Source

pub async fn retry<E>(&mut self, error: E) -> Result<(), E>

Prepares the next refetch, or returns error if no refetch applies.

error is the error that ended the consumer of the latest body, in the error type of the caller. If that body failed in transit and a repeat is left, the method spends the repeat. It then waits for the backoff delay before the next fetch.

The consumer drops the body before it calls this method. So the delay holds no connection and no admission permit.

§Errors

Returns error as it is if the latest body did not fail in transit, or if no repeat is left.

Auto Trait Implementations§

§

impl<'f, 'r> !RefUnwindSafe for Refetch<'f, 'r>

§

impl<'f, 'r> !UnwindSafe for Refetch<'f, 'r>

§

impl<'f, 'r> Forget for Refetch<'f, 'r>

§

impl<'f, 'r> Freeze for Refetch<'f, 'r>
where &'f Fetcher: Freeze, &'r str: Freeze, &'r Validators: Freeze, &'r [(String, String)]: Freeze, &'r BasicAuth: Freeze, *const ArcInner<Atomic<bool>> is !null: Freeze, PhantomData<ArcInner<Atomic<bool>>>: Freeze,

§

impl<'f, 'r> Move for Refetch<'f, 'r>

§

impl<'f, 'r> Send for Refetch<'f, 'r>
where &'f Fetcher: Send, &'r str: Send, &'r Validators: Send, &'r [(String, String)]: Send, &'r BasicAuth: Send, Arc<Atomic<bool>>: Send,

§

impl<'f, 'r> Sync for Refetch<'f, 'r>
where Arc<Inner>: Sync, Arc<[Arc<Atomic<u64>>]>: Sync, RawVecInner: Sync, Arc<Atomic<bool>>: Sync,

§

impl<'f, 'r> Unpin for Refetch<'f, 'r>
where &'f Fetcher: Unpin, &'r str: Unpin, &'r Validators: Unpin, &'r [(String, String)]: Unpin, &'r BasicAuth: Unpin, Arc<Atomic<bool>>: Unpin,

§

impl<'f, 'r> UnsafeUnpin for Refetch<'f, 'r>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more