#[non_exhaustive]pub struct PreparedRequest {
pub method: Method,
pub url: String,
pub query_pairs: Vec<(String, String)>,
pub headers: Vec<(String, String)>,
pub body: Option<Value>,
pub auth: ResolvedAuth,
}Expand description
A fully resolved HTTP request ready to be sent or inspected.
Created by PreparedRequest::from_operation, this struct holds all the
data needed to execute an HTTP request. Consumers can inspect the fields
for dry-run display, verbose logging, or request modification before
calling send.
§Example
let prepared = PreparedRequest::from_operation(
"https://api.example.com",
&Auth::Bearer("token"),
op,
matches,
)?;
// Inspect before sending (dry-run / verbose)
eprintln!("{} {}", prepared.method, prepared.url);
let value = prepared.send(&Client::new())?;Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.method: MethodHTTP method (GET, POST, etc.).
url: StringFully resolved URL with path parameters substituted.
query_pairs: Vec<(String, String)>Query parameters from the API operation.
Auth query parameters (see ResolvedAuth::Query) are kept in the
auth field and applied separately during
send.
headers: Vec<(String, String)>Headers from the API operation.
Auth headers are kept in the auth field.
body: Option<Value>JSON request body, if any.
auth: ResolvedAuthResolved authentication.
Implementations§
Source§impl PreparedRequest
impl PreparedRequest
Sourcepub fn from_operation(
base_url: &str,
auth: &Auth<'_>,
op: &ApiOperation,
matches: &ArgMatches,
) -> Result<Self, DispatchError>
pub fn from_operation( base_url: &str, auth: &Auth<'_>, op: &ApiOperation, matches: &ArgMatches, ) -> Result<Self, DispatchError>
Build a prepared request from an API operation and clap matches.
Trait Implementations§
Source§impl Clone for PreparedRequest
impl Clone for PreparedRequest
Source§fn clone(&self) -> PreparedRequest
fn clone(&self) -> PreparedRequest
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PreparedRequest
impl RefUnwindSafe for PreparedRequest
impl Send for PreparedRequest
impl Sync for PreparedRequest
impl Unpin for PreparedRequest
impl UnsafeUnpin for PreparedRequest
impl UnwindSafe for PreparedRequest
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