Transport

Trait Transport 

Source
pub trait Transport: Send + Sync {
    // Required methods
    fn send_message<'life0, 'async_trait>(
        &'life0 mut self,
        message: JsonRpcMessage,
    ) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn receive_message<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<JsonRpcMessage, TransportError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn close<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;

    // Provided methods
    fn get_state(&self) -> ConnectionState { ... }
    fn get_health(&self) -> TransportHealth { ... }
    fn is_ready(&self) -> bool { ... }
    fn shutdown<'life0, 'async_trait>(
        &'life0 mut self,
        config: ShutdownConfig,
    ) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
    fn force_shutdown<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
    fn reconnect<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
    fn reset<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
}
Expand description

Enhanced transport trait with lifecycle management

Required Methods§

Source

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

Send a message through the transport

Source

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

Receive a message from the transport

Source

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

Close the transport connection gracefully

Provided Methods§

Source

fn get_state(&self) -> ConnectionState

Get current connection state

Source

fn get_health(&self) -> TransportHealth

Get transport health information

Source

fn is_ready(&self) -> bool

Check if transport is ready for operations

Source

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

Initiate graceful shutdown

Source

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

Force immediate shutdown

Source

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

Attempt to reconnect the transport

Source

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

Reset transport state and clear any cached data

Implementors§