Skip to main content

CallEndpoint

Trait CallEndpoint 

Source
pub trait CallEndpoint {
    type Args;
    type Response;

    // Required methods
    fn method() -> Method;
    fn build_path(args: &Self::Args) -> String;
    fn request_body(args: &Self::Args) -> Option<Result<Vec<u8>, ClientError>>;
    fn parse_response(bytes: &[u8]) -> Result<Self::Response, ClientError>;
}
Expand description

Describes how to call a specific endpoint: what arguments it needs, how to build the URL, and how to parse the response.

Required Associated Types§

Source

type Args

The arguments needed to call this endpoint.

Source

type Response

The response type returned on success.

Required Methods§

Source

fn method() -> Method

The HTTP method.

Source

fn build_path(args: &Self::Args) -> String

Build the URL path by substituting captures into the pattern.

Source

fn request_body(args: &Self::Args) -> Option<Result<Vec<u8>, ClientError>>

Serialize the request body, if any.

Source

fn parse_response(bytes: &[u8]) -> Result<Self::Response, ClientError>

Deserialize the response body.

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<P, Req, Res, Q, Err> CallEndpoint for Endpoint<Patch, P, Req, Res, Q, Err>

Source§

impl<P, Req, Res, Q, Err> CallEndpoint for Endpoint<Post, P, Req, Res, Q, Err>

Source§

impl<P, Req, Res, Q, Err> CallEndpoint for Endpoint<Put, P, Req, Res, Q, Err>

Source§

impl<P, Res, Q, Err> CallEndpoint for Endpoint<Delete, P, NoBody, Res, Q, Err>

Source§

impl<P, Res, Q, Err> CallEndpoint for Endpoint<Get, P, NoBody, Res, Q, Err>

Source§

impl<P, Res, Q, Err> CallEndpoint for Endpoint<Head, P, NoBody, Res, Q, Err>

Source§

impl<P, Res, Q, Err> CallEndpoint for Endpoint<Options, P, NoBody, Res, Q, Err>

Implementors§