pub struct Transport<T>where
T: Provider + Send,{ /* private fields */ }
Expand description
An abstract libp2p_core::Transport
implementation.
You shouldn’t need to use this type directly. Use one of the following instead:
tokio::Transport
- [
async_io::Transport
]
Implementations§
source§impl<T> Transport<T>where
T: Provider + Send,
impl<T> Transport<T>where
T: Provider + Send,
sourcepub fn new(config: Config) -> Transport<T>
pub fn new(config: Config) -> Transport<T>
Create a new instance of Transport
.
If you don’t want to specify a Config
, use Transport::default
.
It is best to call this function through one of the type-aliases of this type:
tokio::Transport::new
- [
async_io::Transport::new
]
Trait Implementations§
source§impl<T> Transport for Transport<T>
impl<T> Transport for Transport<T>
source§fn address_translation(
&self,
listen: &Multiaddr,
observed: &Multiaddr,
) -> Option<Multiaddr>
fn address_translation( &self, listen: &Multiaddr, observed: &Multiaddr, ) -> Option<Multiaddr>
When port reuse is disabled and hence ephemeral local ports are
used for outgoing connections, the returned address is the
observed
address with the port replaced by the port of the
listen
address.
If port reuse is enabled, Some(observed)
is returned, as there
is a chance that the observed
address and port are reachable
for other peers if there is a NAT in the way that does endpoint-
independent filtering. Furthermore, even if that is not the case
and TCP hole punching techniques must be used for NAT traversal,
the observed
address is still the one that a remote should connect
to for the purpose of the hole punching procedure, as it represents
the mapped IP and port of the NAT device in front of the local
node.
None
is returned if one of the given addresses is not a TCP/IP
address.
source§fn poll(
self: Pin<&mut Transport<T>>,
cx: &mut Context<'_>,
) -> Poll<TransportEvent<<Transport<T> as Transport>::ListenerUpgrade, <Transport<T> as Transport>::Error>>
fn poll( self: Pin<&mut Transport<T>>, cx: &mut Context<'_>, ) -> Poll<TransportEvent<<Transport<T> as Transport>::ListenerUpgrade, <Transport<T> as Transport>::Error>>
Poll all listeners.
§type Output = <T as Provider>::Stream
type Output = <T as Provider>::Stream
§type Dial = Pin<Box<dyn Future<Output = Result<<Transport<T> as Transport>::Output, <Transport<T> as Transport>::Error>> + Send>>
type Dial = Pin<Box<dyn Future<Output = Result<<Transport<T> as Transport>::Output, <Transport<T> as Transport>::Error>> + Send>>
§type ListenerUpgrade = Ready<Result<<Transport<T> as Transport>::Output, <Transport<T> as Transport>::Error>>
type ListenerUpgrade = Ready<Result<<Transport<T> as Transport>::Output, <Transport<T> as Transport>::Error>>
source§fn listen_on(
&mut self,
id: ListenerId,
addr: Multiaddr,
) -> Result<(), TransportError<<Transport<T> as Transport>::Error>>
fn listen_on( &mut self, id: ListenerId, addr: Multiaddr, ) -> Result<(), TransportError<<Transport<T> as Transport>::Error>>
Multiaddr
for inbound connections with a provided ListenerId
.source§fn remove_listener(&mut self, id: ListenerId) -> bool
fn remove_listener(&mut self, id: ListenerId) -> bool
source§fn dial(
&mut self,
addr: Multiaddr,
) -> Result<<Transport<T> as Transport>::Dial, TransportError<<Transport<T> as Transport>::Error>>
fn dial( &mut self, addr: Multiaddr, ) -> Result<<Transport<T> as Transport>::Dial, TransportError<<Transport<T> as Transport>::Error>>
source§fn dial_as_listener(
&mut self,
addr: Multiaddr,
) -> Result<<Transport<T> as Transport>::Dial, TransportError<<Transport<T> as Transport>::Error>>
fn dial_as_listener( &mut self, addr: Multiaddr, ) -> Result<<Transport<T> as Transport>::Dial, TransportError<<Transport<T> as Transport>::Error>>
Transport::dial
but has the local node act as a listener on the outgoing connection. Read moresource§fn map<F, O>(self, f: F) -> Map<Self, F>
fn map<F, O>(self, f: F) -> Map<Self, F>
source§fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
source§fn or_transport<U>(self, other: U) -> OrTransport<Self, U>
fn or_transport<U>(self, other: U) -> OrTransport<Self, U>
Auto Trait Implementations§
impl<T> !Freeze for Transport<T>
impl<T> !RefUnwindSafe for Transport<T>
impl<T> Send for Transport<T>
impl<T> Sync for Transport<T>
impl<T> Unpin for Transport<T>
impl<T> !UnwindSafe for Transport<T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<TTransport> TransportExt for TTransportwhere
TTransport: Transport,
impl<TTransport> TransportExt for TTransportwhere
TTransport: Transport,
source§fn with_bandwidth_logging<S>(
self,
) -> (Boxed<(PeerId, StreamMuxerBox)>, Arc<BandwidthSinks>)
fn with_bandwidth_logging<S>( self, ) -> (Boxed<(PeerId, StreamMuxerBox)>, Arc<BandwidthSinks>)
Transport
that logs all trafic that passes through the streams
created by it. Read more