Function tetsy_multistream_select::dialer_select_proto[][src]

pub fn dialer_select_proto<R, I>(
    inner: R,
    protocols: I,
    version: Version
) -> DialerSelectFuture<R, I::IntoIter> where
    R: AsyncRead + AsyncWrite,
    I: IntoIterator,
    I::Item: AsRef<[u8]>, 

Returns a Future that negotiates a protocol on the given I/O stream for a peer acting as the dialer (or initiator).

This function is given an I/O stream and a list of protocols and returns a computation that performs the protocol negotiation with the remote. The returned Future resolves with the name of the negotiated protocol and a Negotiated I/O stream.

The chosen message flow for protocol negotiation depends on the numbers of supported protocols given. That is, this function delegates to serial or parallel variant based on the number of protocols given. The number of protocols is determined through the size_hint of the given iterator and thus an inaccurate size estimate may result in a suboptimal choice.

Within the scope of this library, a dialer always commits to a specific tetsy-multistream-select Version, whereas a listener always supports all versions supported by this library. Frictionless tetsy-multistream-select protocol upgrades may thus proceed by deployments with updated listeners, eventually followed by deployments of dialers choosing the newer protocol.