Skip to main content

ProxySocket

Trait ProxySocket 

Source
pub trait ProxySocket {
    // Required methods
    async fn recv_multipart(&mut self) -> Result<Option<Vec<Bytes>>, Error>;
    async fn send_multipart(&mut self, msg: Vec<Bytes>) -> Result<(), Error>;
    fn socket_desc(&self) -> &'static str;
}
Expand description

Socket types that can participate in a proxy.

Sockets must implement multipart message send/receive operations to be used in a proxy pattern.

Note: This trait is designed for single-threaded async runtimes like compio and does not require Send.

Uses native async-fn-in-trait rather than #[async_trait]: the proxy loop forwards every message through recv_multipart/send_multipart, and boxing each of those futures per message was pure overhead on this thread-per-core runtime. AFIT removes the per-message heap allocation. ProxySocket is only ever used behind generics (proxy<F, B, C>), never as dyn ProxySocket, so object safety does not apply; the public-AFIT Send-bound lint is irrelevant to this deliberately !Send API.

Required Methods§

Source

async fn recv_multipart(&mut self) -> Result<Option<Vec<Bytes>>, Error>

Receive a multipart message from the socket.

Returns None if no message is available or connection closed.

Source

async fn send_multipart(&mut self, msg: Vec<Bytes>) -> Result<(), Error>

Send a multipart message to the socket.

§Errors

Returns an error if the send operation fails.

Source

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

Get a description of the socket for logging.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§