Trait libp2prs_core::transport::Transport [−][src]
A transport provides connection-oriented communication between two peers through ordered streams of data (i.e. connections).
Connections are established either by accepting
or dialing on a Transport
. A peer that
obtains a connection by listening is often referred to as the listener and the
peer that initiated the connection through dialing as the dialer, in
contrast to the traditional roles of server and client.
Most transports also provide a form of reliable delivery on the established connections but the precise semantics of these guarantees depend on the specific transport.
This trait is implemented for concrete connection-oriented transport protocols like TCP or Unix Domain Sockets, but also on wrappers that add additional functionality to the dialing or listening process (e.g. name resolution via the DNS).
Associated Types
type Output
[src]
The result of a connection setup process, including protocol upgrades.
Typically the output contains at least a handle to a data stream (i.e. a connection or a substream multiplexer on top of a connection) that provides APIs for sending and receiving data through the connection.
Required methods
fn listen_on(
&mut self,
addr: Multiaddr
) -> Result<IListener<Self::Output>, TransportError>
[src]
&mut self,
addr: Multiaddr
) -> Result<IListener<Self::Output>, TransportError>
Listens on the given Multiaddr
, producing a IListener which can be used to accept
new inbound connections.
Returning an error when there is underlying error in transport.
#[must_use]fn dial<'life0, 'async_trait>(
&'life0 mut self,
addr: Multiaddr
) -> Pin<Box<dyn Future<Output = Result<Self::Output, TransportError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 mut self,
addr: Multiaddr
) -> Pin<Box<dyn Future<Output = Result<Self::Output, TransportError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Dials the given Multiaddr
, returning a outbound connection.
If TransportError::MultiaddrNotSupported
is returned, it means a wrong transport is
used to dial for the address.
fn box_clone(&self) -> ITransport<Self::Output>
[src]
Clones the transport and returns the trait object.
fn protocols(&self) -> Vec<u32>
[src]
Returns the Multiaddr
protocol supported by the transport.
In general, transport supports some concrete protocols, e.g. TCP transport for TCP.
It should always be a match between the transport and the given Multiaddr
to dial/listen.
Otherwise, TransportError::MultiaddrNotSupported
is returned.
Provided methods
fn timeout(self, timeout: Duration) -> TransportTimeout<Self> where
Self: Sized,
[src]
Self: Sized,
Adds a timeout to the connection setup (including upgrades) for all inbound and outbound connections established through the transport.
fn outbound_timeout(self, timeout: Duration) -> TransportTimeout<Self> where
Self: Sized,
[src]
Self: Sized,
Adds a timeout to the connection setup (including upgrades) for all outbound connections established through the transport.
fn inbound_timeout(self, timeout: Duration) -> TransportTimeout<Self> where
Self: Sized,
[src]
Self: Sized,
Adds a timeout to the connection setup (including upgrades) for all inbound connections established through the transport.
Implementors
impl Transport for DummyTransport
[src]
type Output = DummyStream
fn listen_on(
&mut self,
_addr: Multiaddr
) -> Result<IListener<Self::Output>, TransportError>
[src]
&mut self,
_addr: Multiaddr
) -> Result<IListener<Self::Output>, TransportError>
fn dial<'life0, 'async_trait>(
&'life0 mut self,
_addr: Multiaddr
) -> Pin<Box<dyn Future<Output = Result<Self::Output, TransportError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 mut self,
_addr: Multiaddr
) -> Pin<Box<dyn Future<Output = Result<Self::Output, TransportError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn box_clone(&self) -> ITransport<Self::Output>
[src]
fn protocols(&self) -> Vec<u32>
[src]
impl Transport for MemoryTransport
[src]
type Output = Channel
fn listen_on(
&mut self,
addr: Multiaddr
) -> Result<IListener<Self::Output>, TransportError>
[src]
&mut self,
addr: Multiaddr
) -> Result<IListener<Self::Output>, TransportError>
fn dial<'life0, 'async_trait>(
&'life0 mut self,
addr: Multiaddr
) -> Pin<Box<dyn Future<Output = Result<Self::Output, TransportError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 mut self,
addr: Multiaddr
) -> Pin<Box<dyn Future<Output = Result<Self::Output, TransportError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn box_clone(&self) -> ITransport<Self::Output>
[src]
fn protocols(&self) -> Vec<u32>
[src]
impl<InnerTrans> Transport for ProtectorTransport<InnerTrans> where
InnerTrans: Transport + Clone + 'static,
InnerTrans::Output: ConnectionInfo + SplittableReadWrite,
[src]
InnerTrans: Transport + Clone + 'static,
InnerTrans::Output: ConnectionInfo + SplittableReadWrite,
type Output = PnetOutput<InnerTrans::Output>
fn listen_on(
&mut self,
addr: Multiaddr
) -> Result<IListener<Self::Output>, TransportError>
[src]
&mut self,
addr: Multiaddr
) -> Result<IListener<Self::Output>, TransportError>
fn dial<'life0, 'async_trait>(
&'life0 mut self,
addr: Multiaddr
) -> Pin<Box<dyn Future<Output = Result<Self::Output, TransportError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 mut self,
addr: Multiaddr
) -> Pin<Box<dyn Future<Output = Result<Self::Output, TransportError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn box_clone(&self) -> ITransport<Self::Output>
[src]
fn protocols(&self) -> Vec<u32>
[src]
impl<InnerTrans> Transport for TransportTimeout<InnerTrans> where
InnerTrans: Transport + Clone + 'static,
InnerTrans::Output: ConnectionInfo + 'static,
[src]
InnerTrans: Transport + Clone + 'static,
InnerTrans::Output: ConnectionInfo + 'static,
type Output = InnerTrans::Output
fn listen_on(
&mut self,
addr: Multiaddr
) -> Result<IListener<Self::Output>, TransportError>
[src]
&mut self,
addr: Multiaddr
) -> Result<IListener<Self::Output>, TransportError>
Creates a IListener with timeout parameter, which will be used for Ilistener to accept new connections.
fn dial<'life0, 'async_trait>(
&'life0 mut self,
addr: Multiaddr
) -> Pin<Box<dyn Future<Output = Result<Self::Output, TransportError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 mut self,
addr: Multiaddr
) -> Pin<Box<dyn Future<Output = Result<Self::Output, TransportError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Creates a new outgoing connection, with the specified timeout parameter.
fn box_clone(&self) -> ITransport<Self::Output>
[src]
fn protocols(&self) -> Vec<u32>
[src]
impl<InnerTrans, TMux, TSec> Transport for TransportUpgrade<InnerTrans, TMux, TSec> where
InnerTrans: Transport + Clone + 'static,
InnerTrans::Output: ConnectionInfo + ReadEx + WriteEx + Unpin + 'static,
TSec: Upgrader<InnerTrans::Output> + 'static,
TSec::Output: SecureInfo + ReadEx + WriteEx + Unpin,
TMux: Upgrader<TSec::Output> + 'static,
TMux::Output: StreamMuxerEx + 'static,
[src]
InnerTrans: Transport + Clone + 'static,
InnerTrans::Output: ConnectionInfo + ReadEx + WriteEx + Unpin + 'static,
TSec: Upgrader<InnerTrans::Output> + 'static,
TSec::Output: SecureInfo + ReadEx + WriteEx + Unpin,
TMux: Upgrader<TSec::Output> + 'static,
TMux::Output: StreamMuxerEx + 'static,
type Output = IStreamMuxer
fn listen_on(
&mut self,
addr: Multiaddr
) -> Result<IListener<Self::Output>, TransportError>
[src]
&mut self,
addr: Multiaddr
) -> Result<IListener<Self::Output>, TransportError>
fn dial<'life0, 'async_trait>(
&'life0 mut self,
addr: Multiaddr
) -> Pin<Box<dyn Future<Output = Result<Self::Output, TransportError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 mut self,
addr: Multiaddr
) -> Pin<Box<dyn Future<Output = Result<Self::Output, TransportError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,