Trait Api

Source
pub trait Api {
    type Reply;
    type Body: Read;
    type Error;

    // Required methods
    fn method(&self) -> Method;
    fn path(&self) -> String;
    fn query(&self) -> Query<'_>;
    fn headers(&self) -> Headers;
    fn body(&self) -> Self::Body;
    fn parse<Resp>(&self, _: &mut Resp) -> Result<Self::Reply, Self::Error>
       where Resp: HttpResponse;
}
Expand description

Api represents a HTTP API exposing all the request parameters and a function to parse the HTTP response.

Required Associated Types§

Required Methods§

Source

fn method(&self) -> Method

Return the HTTP method used by this API.

Source

fn path(&self) -> String

Return the URL path for this API request.

Source

fn query(&self) -> Query<'_>

Return the URL query for this API request.

Source

fn headers(&self) -> Headers

Return the headers for this HTTP request.

Source

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

Return the body of this HTTP request. If the request doesn’t expect any body (i.e. GET), it should return std::io::Empty.

Source

fn parse<Resp>(&self, _: &mut Resp) -> Result<Self::Reply, Self::Error>
where Resp: HttpResponse,

Parse the HTTP response, received from the actual client, into the type Reply.

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.

Implementors§