pub trait Transport: Send + Sync {
// Required methods
fn send_frame(
&self,
frame: &Frame,
) -> impl Future<Output = Result<(), TransportError>> + Send;
fn recv_frame(
&self,
) -> impl Future<Output = Result<FrameView<'_>, TransportError>> + Send;
fn encoder(&self) -> Box<dyn EncodeCtx + '_>;
fn close(&self) -> impl Future<Output = Result<(), TransportError>> + Send;
}Expand description
A transport moves frames between two peers.
Transports are responsible for:
- Frame serialization/deserialization
- Flow control at the transport level
- Delivering frames reliably (within a session)
Transports are NOT responsible for:
- RPC semantics (channels, methods, deadlines)
- Service dispatch
- Schema management
Invariant: A transport may buffer internally, but must not reorder frames within a channel, and must uphold the lifetime guarantees implied by FrameView.
Required Methods§
Sourcefn send_frame(
&self,
frame: &Frame,
) -> impl Future<Output = Result<(), TransportError>> + Send
fn send_frame( &self, frame: &Frame, ) -> impl Future<Output = Result<(), TransportError>> + Send
Send a frame to the peer.
The frame is borrowed for the duration of the call. The transport may copy it (stream), reference it (in-proc), or encode it into SHM slots depending on implementation.
Sourcefn recv_frame(
&self,
) -> impl Future<Output = Result<FrameView<'_>, TransportError>> + Send
fn recv_frame( &self, ) -> impl Future<Output = Result<FrameView<'_>, TransportError>> + Send
Receive the next frame from the peer.
Returns a FrameView with lifetime tied to internal buffers. Caller must process or copy before calling recv_frame again.
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.