Skip to main content

RestRequest

Trait RestRequest 

Source
pub trait RestRequest {
    type Response: DeserializeOwned;
    type QueryParams: Serialize;
    type Body: Serialize;

    // Required methods
    fn path(&self) -> Cow<'static, str>;
    fn method() -> Method;

    // Provided methods
    fn query_params(&self) -> Option<&Self::QueryParams> { ... }
    fn body(&self) -> Option<&Self::Body> { ... }
    fn timeout(&self) -> Duration { ... }
}
Expand description

Http REST request that can be executed by a RestClient.

Required Associated Types§

Source

type Response: DeserializeOwned

Expected response type if this request was successful.

Source

type QueryParams: Serialize

Serialisable query parameters type - use unit struct () if not required for this request.

Source

type Body: Serialize

Serialisable Body type - use unit struct () if not required for this request.

Required Methods§

Source

fn path(&self) -> Cow<'static, str>

Additional Url path to the resource.

Source

fn method() -> Method

Http reqwest::Method of this request.

Provided Methods§

Source

fn query_params(&self) -> Option<&Self::QueryParams>

Optional query parameters for this request.

Source

fn body(&self) -> Option<&Self::Body>

Optional Body for this request.

Source

fn timeout(&self) -> Duration

Http request timeout Duration.

Takes &self so an implementation may derive the timeout from per-instance/config state (e.g. an operator-tunable timeout captured at construction). The default returns the compile-time [DEFAULT_HTTP_REQUEST_TIMEOUT] and ignores self.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§