Skip to main content

HttpClientCodec

Trait HttpClientCodec 

Source
pub trait HttpClientCodec: CratestackCodec {
    // Required methods
    fn accept_header_value(&self) -> &'static str;
    fn sequence_accept_header_value(&self) -> &'static str;
    fn decode_response<T>(
        &self,
        content_type: &str,
        body: &[u8],
    ) -> Result<T, CratestackError>
       where T: DeserializeOwned;
    fn decode_sequence_response<T>(
        &self,
        content_type: &str,
        body: &[u8],
    ) -> Result<Vec<T>, CratestackError>
       where T: DeserializeOwned;

    // Provided method
    fn payload_accept(&self) -> &'static str { ... }
}

Required Methods§

Source

fn accept_header_value(&self) -> &'static str

Source

fn sequence_accept_header_value(&self) -> &'static str

Source

fn decode_response<T>( &self, content_type: &str, body: &[u8], ) -> Result<T, CratestackError>

Source

fn decode_sequence_response<T>( &self, content_type: &str, body: &[u8], ) -> Result<Vec<T>, CratestackError>

Provided Methods§

Source

fn payload_accept(&self) -> &'static str

The response payload types this codec reads inside a COSE envelope, as a Cratestack-Payload-Accept value: one to eight lowercase type/subtype entries joined by ", ", in order of preference. The default is CONTENT_TYPE alone, which suits a codec that writes and reads the same type; override it for an asymmetric one (a form in, JSON out). A sealed call sends the header only when this is not application/cbor, and the client refuses any answer sealed under a type it does not list.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl HttpClientCodec for CborCodec

Source§

impl HttpClientCodec for JsonCodec

Available on crate feature codec-json only.