Trait Connection

Source
pub trait Connection: Send + Sync {
    // Required methods
    fn send<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        data: &'life1 [u8],
    ) -> 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<Vec<u8>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn info<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = ConnectionInfo> + 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_alive<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn measure_quality<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<ConnectionQuality>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn local_addr(&self) -> Multiaddr;
    fn remote_addr(&self) -> Multiaddr;
}
Expand description

Connection trait for active connections

Required Methods§

Source

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

Send data over the connection

Source

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

Receive data from the connection

Source

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

Get connection info

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 connection

Source

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

Check if connection is alive

Source

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

Measure connection quality

Source

fn local_addr(&self) -> Multiaddr

Get local address

Source

fn remote_addr(&self) -> Multiaddr

Get remote address

Implementors§