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§
sourcetype StreamRead: Iterator<Item = Result<Vec<u8>>> + Send
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.
sourcetype StreamSend: StreamSend
type StreamSend: StreamSend
Send end of a stream.
Required Methods§
sourcefn advertised_addrs(&self) -> Vec<SocketAddr>
fn advertised_addrs(&self) -> Vec<SocketAddr>
Returns the list of advertised addresses known for this connection.
sourcefn close(&self) -> Result<()>
fn close(&self) -> Result<()>
Tears down the connection and releases all attached resources.
§Errors
- If release of attached resources failed.
sourcefn local_addr(&self) -> SocketAddr
fn local_addr(&self) -> SocketAddr
Returns the local address for the connection.
sourcefn open_bidirectional(
&self,
stream_id: StreamId
) -> Result<(Self::StreamRead, Self::StreamSend), Self::Error>
fn open_bidirectional( &self, stream_id: StreamId ) -> Result<(Self::StreamRead, Self::StreamSend), Self::Error>
sourcefn public_key(&self) -> PublicKey
fn public_key(&self) -> PublicKey
Public key of the remote peer.
sourcefn remote_addr(&self) -> SocketAddr
fn remote_addr(&self) -> SocketAddr
Local address(es) to the endpoint listens on.