Skip to main content

Fetcher

Struct Fetcher 

Source
pub struct Fetcher<'a, H: HttpClient, C: RetrySettings> { /* private fields */ }
Expand description

Wraps an HttpClient with a rate-limit throttle and retry/backoff loop.

C supplies the knobs via RetrySettings — typically a vendor SyncConfig.

Implementations§

Source§

impl<'a, H: HttpClient, C: RetrySettings> Fetcher<'a, H, C>

Source

pub fn new(http: &'a H, cfg: &'a C) -> Self

Source

pub fn get(&self, url: &str) -> Result<Vec<u8>, String>

GET with throttle + bounded exponential backoff. On success returns the body; on terminal failure a message with the token redacted.

Source

pub fn get_json(&self, url: &str) -> Result<Value, String>

GET and parse any JSON value.

Source

pub fn get_rows(&self, url: &str) -> Result<Vec<Value>, String>

GET and parse a JSON array of row objects (list / EOD endpoints).

Vendor list endpoints return an array on success and an error object on failure; surface that object’s message (checking the common key shapes across vendors — message / error / Error Message) instead of silently yielding no rows.

Auto Trait Implementations§

§

impl<'a, H, C> !Freeze for Fetcher<'a, H, C>

§

impl<'a, H, C> !RefUnwindSafe for Fetcher<'a, H, C>

§

impl<'a, H, C> !Sync for Fetcher<'a, H, C>

§

impl<'a, H, C> Send for Fetcher<'a, H, C>
where H: Sync, C: Sync,

§

impl<'a, H, C> Unpin for Fetcher<'a, H, C>

§

impl<'a, H, C> UnsafeUnpin for Fetcher<'a, H, C>

§

impl<'a, H, C> UnwindSafe for Fetcher<'a, H, C>

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.