pub trait Request: Send {
type Data: Serialize;
type Response: for<'de> Deserialize<'de>;
const METHOD: Method = Method::GET;
// Required method
fn endpoint(&self) -> Cow<'_, str>;
// Provided methods
fn headers(&self) -> HeaderMap { ... }
fn data(&self) -> RequestData<&Self::Data> { ... }
}
Expand description
The base-trait for requests sent by the client. The trait specifies the full life-cycle of the request, including the endpoint, headers, data, method and eventual response.
Provided Associated Constants§
Required Associated Types§
Sourcetype Data: Serialize
type Data: Serialize
The type of additional data sent with the request. Usually, this will be ()
or Self
.
Sourcetype Response: for<'de> Deserialize<'de>
type Response: for<'de> Deserialize<'de>
The type of the response from the server.
Required Methods§
Provided Methods§
Sourcefn headers(&self) -> HeaderMap
fn headers(&self) -> HeaderMap
Any additional headers that should be sent with the request. Note that common headers such as authorization headers should be set on the client directly.
Sourcefn data(&self) -> RequestData<&Self::Data>
fn data(&self) -> RequestData<&Self::Data>
The formatted request data.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.