Skip to content

Commit

Permalink
feat: Add from_parts and build_split methods to `blocking::Reques…
Browse files Browse the repository at this point in the history
…tBuilder` struct (#2288)
  • Loading branch information
adamaq01 committed May 15, 2024
1 parent 3da5283 commit 03ddcac
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/blocking/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ impl RequestBuilder {
}
}

/// Assemble a builder starting from an existing `Client` and a `Request`.
pub fn from_parts(client: Client, request: Request) -> RequestBuilder {
RequestBuilder {
client,
request: crate::Result::Ok(request),
}
}

/// Add a `Header` to this Request.
///
/// ```rust
Expand Down Expand Up @@ -550,6 +558,15 @@ impl RequestBuilder {
self.request
}

/// Build a `Request`, which can be inspected, modified and executed with
/// `Client::execute()`.
///
/// This is similar to [`RequestBuilder::build()`], but also returns the
/// embedded `Client`.
pub fn build_split(self) -> (Client, crate::Result<Request>) {
(self.client, self.request)
}

/// Constructs the Request and sends it the target URL, returning a Response.
///
/// # Errors
Expand Down

0 comments on commit 03ddcac

Please sign in to comment.