Trait Request

Source
pub trait Request {
    type Body: 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 body(&self) -> RequestBody<&Self::Body> { ... }
}
Expand description

A RING API request.

Provided Associated Constants§

Source

const METHOD: Method = Method::GET

The HTTP method (“verb”) for the request.

Required Associated Types§

Source

type Body: Serialize

The type of the body for this request. TODO(H2CO3): default to ().

Source

type Response: for<'de> Deserialize<'de>

The “return type” of the request.

Required Methods§

Source

fn endpoint(&self) -> Cow<'_, str>

The endpoint: the part of the URL/path that follows the base URL.

Provided Methods§

Source

fn headers(&self) -> HeaderMap

Additional headers for this request.

Source

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

The body of the request, if any

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.

Implementations on Foreign Types§

Source§

impl<R: Request> Request for &R

Source§

const METHOD: Method = R::METHOD

Source§

type Body = <R as Request>::Body

Source§

type Response = <R as Request>::Response

Source§

fn endpoint(&self) -> Cow<'_, str>

Source§

fn headers(&self) -> HeaderMap

Source§

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

Source§

impl<R: Request> Request for &mut R

Source§

const METHOD: Method = R::METHOD

Source§

type Body = <R as Request>::Body

Source§

type Response = <R as Request>::Response

Source§

fn endpoint(&self) -> Cow<'_, str>

Source§

fn headers(&self) -> HeaderMap

Source§

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

Implementors§