Skip to main content

HttpTransport

Trait HttpTransport 

Source
pub trait HttpTransport:
    Clone
    + Send
    + Sync
    + 'static {
    // Required methods
    fn decode_request<T>(
        &self,
        content_type: &str,
        body: &[u8],
    ) -> Result<T, CoolError>
       where T: for<'de> Deserialize<'de>;
    fn encode_response<T>(
        &self,
        content_type: &str,
        status: StatusCode,
        value: &T,
    ) -> Result<Response<Body>, CoolError>
       where T: Serialize + ?Sized;
    fn encode_sequence_response<T>(
        &self,
        content_type: &str,
        status: StatusCode,
        values: &[T],
    ) -> Result<Response<Body>, CoolError>
       where T: Serialize;
    fn encode_sequence_error_response(
        &self,
        content_type: &str,
        status: StatusCode,
        value: &CoolErrorResponse,
    ) -> Result<Response<Body>, CoolError>;
}

Required Methods§

Source

fn decode_request<T>( &self, content_type: &str, body: &[u8], ) -> Result<T, CoolError>
where T: for<'de> Deserialize<'de>,

Source

fn encode_response<T>( &self, content_type: &str, status: StatusCode, value: &T, ) -> Result<Response<Body>, CoolError>
where T: Serialize + ?Sized,

Source

fn encode_sequence_response<T>( &self, content_type: &str, status: StatusCode, values: &[T], ) -> Result<Response<Body>, CoolError>
where T: Serialize,

Source

fn encode_sequence_error_response( &self, content_type: &str, status: StatusCode, value: &CoolErrorResponse, ) -> Result<Response<Body>, CoolError>

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§

Source§

impl<C> HttpTransport for C
where C: CoolCodec,

Source§

impl<Primary, Secondary> HttpTransport for CodecSet<Primary, Secondary>
where Primary: CoolCodec, Secondary: CoolCodec,