Struct libp2p_tcp::Transport

source ·
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:

Implementations§

source§

impl<T> Transport<T>where T: Provider + Send,

source

pub fn new(config: Config) -> Self

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:

Trait Implementations§

source§

impl<T> Default for Transport<T>where T: Provider + Send,

source§

fn default() -> Self

Creates a Transport with reasonable defaults.

This transport will have port-reuse disabled.

source§

impl<T> Transport for Transport<T>where T: Provider + Send + 'static, T::Listener: Unpin, T::Stream: Unpin,

source§

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 Self>, cx: &mut Context<'_> ) -> Poll<TransportEvent<Self::ListenerUpgrade, Self::Error>>

Poll all listeners.

§

type Output = <T as Provider>::Stream

The result of a connection setup process, including protocol upgrades. Read more
§

type Error = Error

An error that occurred during connection setup.
§

type Dial = Pin<Box<dyn Future<Output = Result<<Transport<T> as Transport>::Output, <Transport<T> as Transport>::Error>> + Send + 'static, Global>>

A pending Output for an outbound connection, obtained from dialing.
§

type ListenerUpgrade = Ready<Result<<Transport<T> as Transport>::Output, <Transport<T> as Transport>::Error>>

A pending Output for an inbound connection, obtained from the Transport stream. Read more
source§

fn listen_on( &mut self, addr: Multiaddr ) -> Result<ListenerId, TransportError<Self::Error>>

Listens on the given [Multiaddr] for inbound connections.
source§

fn remove_listener(&mut self, id: ListenerId) -> bool

Remove a listener. Read more
source§

fn dial( &mut self, addr: Multiaddr ) -> Result<Self::Dial, TransportError<Self::Error>>

Dials the given [Multiaddr], returning a future for a pending outbound connection. Read more
source§

fn dial_as_listener( &mut self, addr: Multiaddr ) -> Result<Self::Dial, TransportError<Self::Error>>

As Transport::dial but has the local node act as a listener on the outgoing connection. Read more
source§

fn map<F, O>(self, f: F) -> Map<Self, F>where Self: Sized, F: FnOnce(Self::Output, ConnectedPoint) -> O,

Applies a function on the connections created by the transport.
source§

fn map_err<F, E>(self, f: F) -> MapErr<Self, F>where Self: Sized, F: FnOnce(Self::Error) -> E,

Applies a function on the errors generated by the futures of the transport.
source§

fn or_transport<U>(self, other: U) -> OrTransport<Self, U>where Self: Sized, U: Transport, <U as Transport>::Error: 'static,

Adds a fallback transport that is used when encountering errors while establishing inbound or outbound connections. Read more
source§

fn and_then<C, F, O>(self, f: C) -> AndThen<Self, C>where Self: Sized, C: FnOnce(Self::Output, ConnectedPoint) -> F, F: TryFuture<Ok = O>, <F as TryFuture>::Error: Error + 'static,

Applies a function producing an asynchronous result to every connection created by this transport. Read more
source§

fn upgrade(self, version: Version) -> Builder<Self>where Self: Sized, Self::Error: 'static,

Begins a series of protocol upgrades via an upgrade::Builder.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for Transport<T>

§

impl<T> Send for Transport<T>

§

impl<T> Sync for Transport<T>where <T as Provider>::IfWatcher: Sync, <T as Provider>::Listener: Sync, <T as Provider>::Stream: Sync,

§

impl<T> Unpin for Transport<T>

§

impl<T> !UnwindSafe for Transport<T>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V