DirectChannel

Trait DirectChannel 

Source
pub trait DirectChannel:
    Send
    + Sync
    + Any {
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn connect<'life0, 'async_trait>(
        &'life0 mut self,
        peer: PeerId,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn send<'life0, 'async_trait>(
        &'life0 mut self,
        peer: PeerId,
        data: Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn close<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn close_shared<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn as_any(&self) -> &dyn Any;
}
Expand description

Trait para a comunicação direta com outro par na rede.

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

Required Methods§

Source

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

Espera até que a conexão com o outro par seja estabelecida.

Source

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

Envia dados para o outro par.

Source

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

Fecha a conexão.

Source

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

Fecha a conexão usando referência compartilhada (&self). Este método permite fechar o canal quando usado dentro de Arc<>.

Source

fn as_any(&self) -> &dyn Any

Método auxiliar para downcast

Implementors§