Skip to main content

Protocol

Trait Protocol 

Source
pub trait Protocol {
    type Incoming;
    type Outgoing;
    type Body: Body;
    type InternalRequest;
    type InternalResponse;

    // Required methods
    fn into_internal(message: Self::Incoming) -> Self::InternalRequest;
    fn from_internal(response: Self::InternalResponse) -> Self::Outgoing;
}
Expand description

通用协议适配抽象

Protocol trait 将外部协议消息与框架内部处理流程解耦,允许按需指定 内部使用的请求/响应类型,从而支持 HTTP、MQTT 等不同协议场景。

Required Associated Types§

Source

type Incoming

外部协议的请求载体(如 hyper::Request、MQTT 报文等)。

Source

type Outgoing

外部协议的响应载体。

Source

type Body: Body

框架内部使用的响应体实现。

Source

type InternalRequest

框架内部处理的请求类型(如 silent::Request 或自定义上下文)。

Source

type InternalResponse

框架内部处理的响应类型。

Required Methods§

Source

fn into_internal(message: Self::Incoming) -> Self::InternalRequest

将外部协议请求转换为框架内部请求类型。

Source

fn from_internal(response: Self::InternalResponse) -> Self::Outgoing

将框架内部响应转换为外部协议响应。

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§