Enum libp2p_core::upgrade::Version[][src]

pub enum Version {
    V1,
    V1Lazy,
}

Supported multistream-select protocol versions.

Variants

V1

Version 1 of the multistream-select protocol. See 1 and 2.

V1Lazy

A lazy variant of version 1 that is identical on the wire but delays sending of protocol negotiation data as much as possible.

Delaying the sending of protocol negotiation data can result in significantly fewer network roundtrips used for the negotiation, up to 0-RTT negotiation.

0-RTT negotiation is achieved if the dialer supports only a single application protocol. In that case the dialer immedidately settles on that protocol, buffering the negotiation messages to be sent with the first round of application protocol data (or an attempt is made to read from the Negotiated I/O stream).

A listener receiving a V1Lazy header will similarly delay sending of the protocol confirmation. Though typically the listener will need to read the request data before sending its response, thus triggering sending of the protocol confirmation, which, in absence of additional buffering on lower layers will result in at least two response frames to be sent.

V1Lazy is specific to rust-libp2p: While the wire protocol is identical to V1, delayed sending of protocol negotiation frames is only safe under the following assumptions:

  1. The dialer is assumed to always send the first multistream-select protocol message immediately after the multistream header, without first waiting for confirmation of that header. Since the listener delays sending the protocol confirmation, a deadlock situation may otherwise occurs that is only resolved by a timeout. This assumption is trivially satisfied if both peers support and use V1Lazy.

  2. When nesting multiple protocol negotiations, the listener is either known to support all of the dialer’s optimistically chosen protocols or there is no intermediate protocol without a payload and none of the protocol payloads has the potential for being mistaken for a multistream-select protocol message. This avoids rare edge-cases whereby the listener may not recognize upgrade boundaries and erroneously process a request despite not supporting one of the intermediate protocols that the dialer committed to. See 1 and 2.

Trait Implementations

impl Clone for Version[src]

impl Copy for Version[src]

impl Debug for Version[src]

impl Default for Version[src]

impl Eq for Version[src]

impl PartialEq<Version> for Version[src]

impl StructuralEq for Version[src]

impl StructuralPartialEq for Version[src]

Auto Trait Implementations

impl RefUnwindSafe for Version

impl Send for Version

impl Sync for Version

impl Unpin for Version

impl UnwindSafe for Version

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[src]

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>, 
[src]