Trait tendermint_p2p::transport::Connection

source ·
pub trait Connection: Send {
    type Error;
    type StreamRead: Iterator<Item = Result<Vec<u8>>> + Send;
    type StreamSend: StreamSend;

    // Required methods
    fn advertised_addrs(&self) -> Vec<SocketAddr>;
    fn close(&self) -> Result<()>;
    fn local_addr(&self) -> SocketAddr;
    fn open_bidirectional(
        &self,
        stream_id: StreamId
    ) -> Result<(Self::StreamRead, Self::StreamSend), Self::Error>;
    fn public_key(&self) -> PublicKey;
    fn remote_addr(&self) -> SocketAddr;
}
Expand description

Trait which describes the core concept of a connection between two peers established by [Transport].

Required Associated Types§

source

type Error

Errors emitted by the connection.

source

type StreamRead: Iterator<Item = Result<Vec<u8>>> + Send

Read end of a bidirectional stream. Carries a finite stream of framed messages. Decoding is left to the caller and should correspond to the type of stream.

source

type StreamSend: StreamSend

Send end of a stream.

Required Methods§

source

fn advertised_addrs(&self) -> Vec<SocketAddr>

Returns the list of advertised addresses known for this connection.

source

fn close(&self) -> Result<()>

Tears down the connection and releases all attached resources.

§Errors
  • If release of attached resources failed.
source

fn local_addr(&self) -> SocketAddr

Returns the local address for the connection.

source

fn open_bidirectional( &self, stream_id: StreamId ) -> Result<(Self::StreamRead, Self::StreamSend), Self::Error>

Opens a new bi-bidirectional stream for the given StreamId.

§Errors
  • If the stream type is not supported.
  • If the peer is gone.
  • If resources necessary for the stream creation aren’t available/accessible.
source

fn public_key(&self) -> PublicKey

Public key of the remote peer.

source

fn remote_addr(&self) -> SocketAddr

Local address(es) to the endpoint listens on.

Implementors§