Skip to main content

RequestBuilder

Struct RequestBuilder 

Source
pub struct RequestBuilder { /* private fields */ }
Expand description

Builds a Request while deferring parsing and serialization errors.

Implementations§

Source§

impl RequestBuilder

Source

pub async fn enqueue( self, queue: &dyn RequestQueue, ) -> Result<QueueOpInfo, CrawlError>

Builds and adds this request to a queue.

Source

pub fn url(self, url: impl IntoUrl) -> Self

Sets the request URL.

Source

pub fn method(self, method: Method) -> Self

Sets the HTTP method.

Source

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

Appends a header, deferring validation until Self::build.

Source

pub fn headers(self, headers: HeaderMap) -> Self

Replaces all currently configured headers.

Source

pub fn body(self, body: RequestBody) -> Self

Sets the request body.

Source

pub fn json<T: Serialize>(self, value: &T) -> Self

Serializes and sets a JSON request body.

Source

pub fn form(self, pairs: impl IntoIterator<Item = (String, String)>) -> Self

Sets an ordered form request body.

Source

pub fn label(self, label: impl Into<String>) -> Self

Sets the routing label.

Source

pub fn user_data(self, user_data: UserData) -> Self

Replaces the request’s user data.

Source

pub fn user_data_entry<T: Serialize>( self, key: impl Into<String>, value: &T, ) -> Self

Serializes and inserts an entry into user data.

Source

pub fn max_retries(self, max_retries: u32) -> Self

Sets the per-request retry limit.

Source

pub fn no_retry(self, no_retry: bool) -> Self

Enables or disables retries.

Source

pub fn skip_navigation(self, skip_navigation: bool) -> Self

Controls whether navigation is skipped.

Source

pub fn unique_key(self, unique_key: impl Into<String>) -> Self

Overrides the computed queue deduplication key.

Source

pub fn forefront(self, forefront: bool) -> Self

Controls whether a future queue enqueue places this request at the front.

Source

pub fn is_forefront(&self) -> bool

Returns whether future queue enqueue convenience should use the forefront.

Source

pub fn crawl_depth(self, crawl_depth: u32) -> Self

Sets the discovery depth.

Source

pub fn build(self) -> Result<Request, RequestBuildError>

Validates this builder and creates a request.

Trait Implementations§

Source§

impl Debug for RequestBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RequestBuilder

Source§

fn default() -> RequestBuilder

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> 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, 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.
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