Struct RequestBuilder

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

A builder to construct the properties of a Request.

To construct a RequestBuilder, refer to the Client documentation.

Implementations§

Source§

impl RequestBuilder

Source

pub fn new(client: Client, builder: Builder) -> RequestBuilder

Constructs a new request.

Source

pub fn uri<U: Into<Uri>>(self, uri: U) -> RequestBuilder

Set uri to this Request.

Source

pub fn header<K, V>(self, key: K, value: V) -> RequestBuilder

Add a Header to this Request.

Source

pub fn header_line<L: Into<String>>(self, lines: L) -> RequestBuilder

Add a Header from lines to this Request.

Source

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

Add a set of Headers to the existing ones on this Request.

The headers will be merged in to any already set.

Source

pub fn body<T: Into<Body>>(self, body: T) -> RequestBuilder

Set the request body.

Source

pub fn raw<R: Into<Bytes>>(self, raw: R, unsafe_raw: bool) -> RequestBuilder

set raw request

Source

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

Build a Request, which can be inspected, modified and executed with Client::execute().

Source

pub async fn send(self) -> Result<Response>

Constructs the Request and sends it to the target URL, returning a future Response.

§Errors

This method fails if there was an error while sending request, redirect loop was detected or redirect limit was exhausted.

§Example
let response = slinger::Client::new()
    .get("https://hyper.rs")
    .send().await?;

Trait Implementations§

Source§

impl Default for RequestBuilder

Source§

fn default() -> Self

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