Skip to main content

Endpoint

Trait Endpoint 

Source
pub trait Endpoint {
    // Required method
    fn path(&self) -> Cow<'static, str>;

    // Provided methods
    fn ignore_errors(&self) -> bool { ... }
    fn method(&self) -> Method { ... }
    fn headers(&self) -> Result<Option<HeaderMap>, HeaderError> { ... }
    fn query_params(&self) -> Option<QueryParamPairs> { ... }
    fn url(&self) -> String { ... }
    fn body(&self) -> Result<Option<(Cow<'static, str>, Vec<u8>)>, BodyError> { ... }
    fn deserialize<T: DeserializeOwned>(
        &self,
        response: Response<Bytes>,
    ) -> Result<T, BodyError> { ... }
}
Expand description

A trait for providing the necessary information for a single REST API endpoint

Required Methods§

Source

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

The path for the endpoint.

Provided Methods§

Source

fn ignore_errors(&self) -> bool

Ignores any errors returned by the API.

Source

fn method(&self) -> Method

The method for the endpoint.

Source

fn headers(&self) -> Result<Option<HeaderMap>, HeaderError>

Any additional headers for the endpoint.

Source

fn query_params(&self) -> Option<QueryParamPairs>

The query parameters for the endpoint.

Source

fn url(&self) -> String

Builds the full URL, including query.

Source

fn body(&self) -> Result<Option<(Cow<'static, str>, Vec<u8>)>, BodyError>

The body for the endpoint.

Returns the Content-Encoding header for the data as well as the data itself.

Source

fn deserialize<T: DeserializeOwned>( &self, response: Response<Bytes>, ) -> Result<T, BodyError>

Deserialize the response bytes.

Defaults to using serde_json::from_slice.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§