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§
Sourcetype InternalRequest
type InternalRequest
框架内部处理的请求类型(如 silent::Request 或自定义上下文)。
Sourcetype InternalResponse
type InternalResponse
框架内部处理的响应类型。
Required Methods§
Sourcefn into_internal(message: Self::Incoming) -> Self::InternalRequest
fn into_internal(message: Self::Incoming) -> Self::InternalRequest
将外部协议请求转换为框架内部请求类型。
Sourcefn from_internal(response: Self::InternalResponse) -> Self::Outgoing
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.