Struct libp2p_relay::RelayTransport[][src]

pub struct RelayTransport<T: Clone> { /* fields omitted */ }

A Transport wrapping another Transport enabling relay capabilities.

Allows the local node to:

  1. Use inner wrapped transport as before.

    relay_transport.dial(Multiaddr::empty().with(Protocol::Memory(42)));
  2. Establish relayed connections by dialing /p2p-circuit addresses.

    let dst_addr_via_relay = Multiaddr::empty()
        .with(Protocol::Memory(40)) // Relay address.
        .with(Protocol::P2p(PeerId::random().into())) // Relay peer id.
        .with(Protocol::P2pCircuit) // Signal to connect via relay and not directly.
        .with(Protocol::Memory(42)) // Destination address.
        .with(Protocol::P2p(PeerId::random().into())); // Destination peer id.
    relay_transport.dial(dst_addr_via_relay).unwrap();
  3. Listen for incoming relayed connections via specific relay.

    let relay_addr = Multiaddr::empty()
        .with(Protocol::Memory(40)) // Relay address.
        .with(Protocol::P2p(PeerId::random().into())) // Relay peer id.
        .with(Protocol::P2pCircuit); // Signal to listen via remote relay node.
    relay_transport.listen_on(relay_addr).unwrap();
  4. Listen for incoming relayed connections via any relay.

    Note: Without this listener, incoming relayed connections from relays, that the local node is not explicitly listening via, are dropped.

    let addr = Multiaddr::empty()
        .with(Protocol::P2pCircuit); // Signal to listen via any relay.
    relay_transport.listen_on(addr).unwrap();

Trait Implementations

impl<T: Clone> Clone for RelayTransport<T>[src]

impl<T: Transport + Clone> Transport for RelayTransport<T>[src]

type Output = EitherOutput<<T as Transport>::Output, Connection>

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

type Error = EitherError<<T as Transport>::Error, RelayError>

An error that occurred during connection setup.

type Listener = RelayListener<T>

A stream of Outputs for inbound connections. Read more

type ListenerUpgrade = RelayedListenerUpgrade<T>

A pending Output for an inbound connection, obtained from the Listener stream. Read more

type Dial = EitherFuture<<T as Transport>::Dial, BoxFuture<'static, Result<Connection, RelayError>>>

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

Auto Trait Implementations

impl<T> !RefUnwindSafe for RelayTransport<T>

impl<T> Send for RelayTransport<T> where
    T: Send

impl<T> Sync for RelayTransport<T> where
    T: Sync

impl<T> Unpin for RelayTransport<T> where
    T: Unpin

impl<T> !UnwindSafe for RelayTransport<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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