Skip to main content

BricksetRequest

Trait BricksetRequest 

Source
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.

Required Methods§

Source

fn encode_query<T>(&self, query: &mut Serializer<'_, T>) -> Result<(), Error>
where T: Target,

Encode method parameters via a URL serializer.

Source

fn method_name(&self) -> &'static str

The request’s method name.

Provided Methods§

Source

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.

Source

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".

Implementors§