Struct libp2p_core::transport::upgrade::Builder[][src]

pub struct Builder<T> { /* fields omitted */ }

A Builder facilitates upgrading of a Transport for use with a Network.

The upgrade process is defined by the following stages:

authenticate{1} -> apply{*} -> multiplex{1}

It thus enforces the following invariants on every transport obtained from multiplex:

  1. The transport must be authenticated and multiplexed.
  2. Authentication must precede the negotiation of a multiplexer.
  3. Applying a multiplexer is the last step in the upgrade process.
  4. The Transport::Output conforms to the requirements of a Network, namely a tuple of a PeerId (from the authentication upgrade) and a StreamMuxer (from the multiplexing upgrade).

Implementations

impl<T> Builder<T> where
    T: Transport,
    T::Error: 'static, 
[src]

pub fn new(inner: T, version: Version) -> Builder<T>[src]

Creates a Builder over the given (base) Transport.

pub fn authenticate<C, D, U, E>(
    self,
    upgrade: U
) -> Authenticated<AndThen<T, impl FnOnce(C, ConnectedPoint) -> Authenticate<C, U> + Clone>> where
    T: Transport<Output = C>,
    C: AsyncRead + AsyncWrite + Unpin,
    D: AsyncRead + AsyncWrite + Unpin,
    U: InboundUpgrade<Negotiated<C>, Output = (PeerId, D), Error = E>,
    U: OutboundUpgrade<Negotiated<C>, Output = (PeerId, D), Error = E> + Clone,
    E: Error + 'static, 
[src]

Upgrades the transport to perform authentication of the remote.

The supplied upgrade receives the I/O resource C and must produce a pair (PeerId, D), where D is a new I/O resource. The upgrade must thus at a minimum identify the remote, which typically involves the use of a cryptographic authentication protocol in the context of establishing a secure channel.

Transitions

  • I/O upgrade: C -> (PeerId, D).
  • Transport output: C -> (PeerId, D)

Trait Implementations

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

Auto Trait Implementations

impl<T> RefUnwindSafe for Builder<T> where
    T: RefUnwindSafe
[src]

impl<T> Send for Builder<T> where
    T: Send
[src]

impl<T> Sync for Builder<T> where
    T: Sync
[src]

impl<T> Unpin for Builder<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for Builder<T> where
    T: UnwindSafe
[src]

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>,