Skip to main content

Protocol

Trait Protocol 

Source
pub trait Protocol: Clone {
    type InnerType: Serialize;

    // Required methods
    fn new() -> Result<Self>
       where Self: Sized;
    fn to_request(
        &self,
        method: &str,
        request: &Self::InnerType,
    ) -> Result<(String, Self::InnerType)>;
    fn from_request(
        &self,
        content: &[u8],
        encoding: Option<Encoding>,
    ) -> Result<Self::InnerType>;
}
Expand description

Contract definition of the protocol.

Required Associated Types§

Required Methods§

Source

fn new() -> Result<Self>
where Self: Sized,

Create a new instance of the protocol.

Source

fn to_request( &self, method: &str, request: &Self::InnerType, ) -> Result<(String, Self::InnerType)>

Build the Request for this protocol.

Returning the request to send to the transport and also a addons info to the URL.

Like in post there is informtion to add to the base URl.

Source

fn from_request( &self, content: &[u8], encoding: Option<Encoding>, ) -> Result<Self::InnerType>

Build the response fom the response

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§