pub struct RequestBuilder { /* private fields */ }Expand description
A request under construction. Finish it with send.
Implementations§
Source§impl RequestBuilder
impl RequestBuilder
Sourcepub fn header(self, name: &str, value: &str) -> Self
pub fn header(self, name: &str, value: &str) -> Self
Set a header, replacing any previous value.
Sourcepub fn query<T: Serialize>(self, pairs: &T) -> Self
pub fn query<T: Serialize>(self, pairs: &T) -> Self
Append a query string built from pairs.
Existing query parameters on the URL are kept; these are added after them.
Sourcepub fn body(self, body: impl Into<Bytes>) -> Self
pub fn body(self, body: impl Into<Bytes>) -> Self
Send body verbatim, with no Content-Type of its own.
Sourcepub fn json<T: Serialize>(self, value: &T) -> Self
pub fn json<T: Serialize>(self, value: &T) -> Self
Serialize value as JSON and set Content-Type: application/json.
Sourcepub async fn send(self) -> Result<Response, ClientError>
pub async fn send(self) -> Result<Response, ClientError>
Send the request and read the whole response.
§Errors
Any ClientError. A non-2xx status is not an error: it is a
response, and whether a 404 is a failure is the caller’s judgement.
Use Response::error_for_status to opt into the other convention.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RequestBuilder
impl !RefUnwindSafe for RequestBuilder
impl !UnwindSafe for RequestBuilder
impl Send for RequestBuilder
impl Sync for RequestBuilder
impl Unpin for RequestBuilder
impl UnsafeUnpin 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