[−][src]Function multistream_select::dialer_select_proto
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
[dialer_select_proto_serial
] or [dialer_select_proto_parallel
]
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
multistream-select protocol Version
, whereas a listener always supports
all versions supported by this library. Frictionless multistream-select
protocol upgrades may thus proceed by deployments with updated listeners,
eventually followed by deployments of dialers choosing the newer protocol.