Skip to main content

Transport

Trait Transport 

Source
pub trait Transport: Send {
    // Required methods
    fn send<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        message: &'life1 JsonRpcMessage,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn receive<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<Option<JsonRpcMessage>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn close<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn is_closed(&self) -> bool;
}
Expand description

Transport trait for JSON-RPC communication

Implementations provide bidirectional message transport with proper framing and error handling.

Note: Only Send is required since async transports typically operate in single-threaded async contexts.

Required Methods§

Source

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

Send a message through the transport

Source

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

Receive a message from the transport

Source

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

Close the transport

Source

fn is_closed(&self) -> bool

Check if the transport is closed

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§