pub trait MessageWriter: Send + 'static {
// Required methods
fn send(
&mut self,
bytes: Bytes,
) -> impl Future<Output = Result<(), TransportError>> + Send;
fn flush(
&mut self,
) -> impl Future<Output = Result<(), TransportError>> + Send;
fn close(
&mut self,
) -> impl Future<Output = Result<(), TransportError>> + Send;
}Expand description
通用连接、Session、请求和事件契约;与独立 Vendor 绑定使用相同运行时。 完整文本消息传输契约。 唯一 Writer owner 操作的写边界;不得在等待时阻挡 Reader。
Required Methods§
Sourcefn send(
&mut self,
bytes: Bytes,
) -> impl Future<Output = Result<(), TransportError>> + Send
fn send( &mut self, bytes: Bytes, ) -> impl Future<Output = Result<(), TransportError>> + Send
接受完整文本消息;成功不证明远端接收,资源可保持到 flush。
async fn write<W: ydp_core::MessageWriter>(writer: &mut W) { let _ = writer.send(bytes::Bytes::from_static(b"{}")).await; }Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".