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>;
    fn encode_sequence_stream_response<T, S>(
        &self,
        content_type: &str,
        status: StatusCode,
        values: S,
    ) -> Result<Response<Body>, CoolError>
       where T: Serialize + Send + 'static,
             S: Stream<Item = Result<T, CoolError>> + Send + 'static;
}

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>

Source

fn encode_sequence_stream_response<T, S>( &self, content_type: &str, status: StatusCode, values: S, ) -> Result<Response<Body>, CoolError>
where T: Serialize + Send + 'static, S: Stream<Item = Result<T, CoolError>> + Send + 'static,

Genuinely incremental counterpart to Self::encode_sequence_response for @stream procedures (cratestack#283): values is encoded and flushed item-by-item via axum::body::Body::from_stream instead of collected into a Vec first. Only meaningful for application/cbor-seq — implementations reject any other content_type, mirroring how the higher-level encode_transport_stream_result_with_status_for only calls this when cbor-seq was negotiated (anything else falls back to the buffered encode_sequence_response path there).

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

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

Source§

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