pub trait BricksetRequest {
// Required methods
fn encode_query<T>(
&self,
query: &mut Serializer<'_, T>,
) -> Result<(), Error>
where T: Target;
fn method_name(&self) -> &'static str;
// Provided methods
fn to_request_url(&self) -> Result<Url, Error> { ... }
fn to_reqwest(&self, client: &Client) -> Result<Request, Error> { ... }
}Expand description
Implemented by any type that can be turned into a BrickSet API request.
BricksetRequest::to_request_urlcreates a URL containing the request method and query parameters.BricksetRequest::to_reqwestcreates a POSTreqwest::Requestwith the query paramters url-encoded in the body.
Required Methods§
Sourcefn encode_query<T>(&self, query: &mut Serializer<'_, T>) -> Result<(), Error>where
T: Target,
fn encode_query<T>(&self, query: &mut Serializer<'_, T>) -> Result<(), Error>where
T: Target,
Encode method parameters via a URL serializer.
Sourcefn method_name(&self) -> &'static str
fn method_name(&self) -> &'static str
The request’s method name.
Provided Methods§
Sourcefn to_request_url(&self) -> Result<Url, Error>
fn to_request_url(&self) -> Result<Url, Error>
Create a URL representing the request. All request parameters will appear in the URL.
NOTE: It is better practice to only put the method name in the request URL, and use
Self::encode_query to put the parameters in the request’s body.
Sourcefn to_reqwest(&self, client: &Client) -> Result<Request, Error>
fn to_reqwest(&self, client: &Client) -> Result<Request, Error>
Build a reqwest::Request from self. The resulting reqwest::Request will
always be a POST request with all method parameters encoded into the body, using
content type application/x-www-form-urlencoded.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".