Struct HttpRequestBuilder

Source
pub struct HttpRequestBuilder(/* private fields */);
Expand description

A builder for constructing an HttpRequest.

Implementations§

Source§

impl HttpRequestBuilder

Source

pub fn uri(self, uri: Url) -> Self

Sets the URI for the HTTP request.

§Arguments
  • uri - The new URL to which the request will be sent.
§Returns

A mutable reference to self, allowing further chaining of builder methods.

Source

pub fn push_header(&mut self, name: impl Into<String>, value: impl Into<String>)

Adds a header to the HTTP request.

§Arguments
  • name - The name of the header.
  • value - The value of the header.

This method mutably modifies the builder, allowing headers to be added in sequence.

Source

pub fn set_timeout(&mut self, timeout_ms: u64)

Sets a timeout for the HTTP request in milliseconds.

§Arguments
  • timeout_ms - The duration of the timeout in milliseconds.

This method mutably modifies the builder, setting an optional timeout for the request.

Source

pub fn json<T: Serialize + ?Sized>(self, body: &T) -> HttpRequest

Sets a JSON body for the HTTP request and adds the appropriate Content-Type header.

§Type Parameters
  • T - A type that implements Serialize.
§Arguments
  • body - The data to be serialized into JSON format and set as the body of the request.

This method constructs a new HttpRequest with a JSON payload, returning it for execution.

Source

pub fn form<T: Serialize + ?Sized>(self, body: &T) -> HttpRequest

Sets a form-encoded body for the HTTP request and adds the appropriate Content-Type header.

§Type Parameters
  • T - A type that implements Serialize.
§Arguments
  • body - The data to be serialized into form-urlencoded format and set as the body of the request.

This method constructs a new HttpRequest with a URL-encoded payload, returning it for execution.

Source

pub fn body(self, body: Vec<u8>) -> HttpRequest

Sets a raw byte array as the body for the HTTP request.

§Arguments
  • body - The data to be set as the body of the request in Vec<u8> format.

This method constructs and returns a new HttpRequest with the specified body.

Source

pub fn build(self) -> HttpRequest

Constructs a fully configured HttpRequest from the builder.

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, 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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T