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
impl RequestBuilder
Sourcepub fn new(client: Client, builder: Builder) -> RequestBuilder
pub fn new(client: Client, builder: Builder) -> RequestBuilder
Constructs a new request.
Sourcepub fn uri<U: Into<Uri>>(self, uri: U) -> RequestBuilder
pub fn uri<U: Into<Uri>>(self, uri: U) -> RequestBuilder
Set uri
to this Request.
Sourcepub fn header<K, V>(self, key: K, value: V) -> RequestBuilderwhere
HeaderName: TryFrom<K>,
HeaderValue: TryFrom<V>,
<HeaderName as TryFrom<K>>::Error: Into<Error>,
<HeaderValue as TryFrom<V>>::Error: Into<Error>,
pub fn header<K, V>(self, key: K, value: V) -> RequestBuilderwhere
HeaderName: TryFrom<K>,
HeaderValue: TryFrom<V>,
<HeaderName as TryFrom<K>>::Error: Into<Error>,
<HeaderValue as TryFrom<V>>::Error: Into<Error>,
Add a Header
to this Request.
Sourcepub fn header_line<L: Into<String>>(self, lines: L) -> RequestBuilder
pub fn header_line<L: Into<String>>(self, lines: L) -> RequestBuilder
Add a Header
from lines to this Request.
Sourcepub fn headers(self, headers: HeaderMap) -> RequestBuilder
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.
Sourcepub fn body<T: Into<Body>>(self, body: T) -> RequestBuilder
pub fn body<T: Into<Body>>(self, body: T) -> RequestBuilder
Set the request body.
Sourcepub fn build(self) -> Result<Request>
pub fn build(self) -> Result<Request>
Build a Request
, which can be inspected, modified and executed with
Client::execute()
.
Sourcepub async fn send(self) -> Result<Response>
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§
Auto Trait Implementations§
impl !Freeze for RequestBuilder
impl !RefUnwindSafe for RequestBuilder
impl Send for RequestBuilder
impl Sync for RequestBuilder
impl Unpin for RequestBuilder
impl !UnwindSafe for RequestBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more