Skip to main content

MeshStream

Trait MeshStream 

Source
pub trait MeshStream:
    Send
    + Sync
    + 'static {
    // Required methods
    fn send<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        data: &'life1 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<(), MeshError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn recv<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, MeshError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn close<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), MeshError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn remote_addr(&self) -> Option<SocketAddr>;
}
Expand description

A bidirectional byte stream over any transport.

§Cancel-safety (ADR-010 / WEFT-18)

recv must be cancel-safe: it is raced inside tokio::select! in the mesh peer loop (boot.rs bidirectional accept path). If a future is dropped mid-frame, the next recv on the same stream must resume cleanly without length-prefix desync. Implementations that stage multi-step reads (read_exact of length then body) must keep partial progress on self.

send is typically invoked only after a select! arm wins (not as a racing future). Prefer making multi-write sends resilient to task drop, but cancel-safety of recv is the load-bearing contract for mesh correctness.

Required Methods§

Source

fn send<'life0, 'life1, 'async_trait>( &'life0 mut self, data: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<(), MeshError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send raw bytes over the stream.

Source

fn recv<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, MeshError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Receive raw bytes from the stream.

Cancel-safe: may be dropped while pending inside tokio::select!.

Source

fn close<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), MeshError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Close the stream gracefully.

Source

fn remote_addr(&self) -> Option<SocketAddr>

Get the remote address if available.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§