Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 4 additions & 22 deletions misc/multistream-select/src/dialer_select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,23 +128,14 @@ where
/// A `Future` returned by [`dialer_select_proto_serial`] which negotiates
/// a protocol iteratively by considering one protocol after the other.
#[pin_project::pin_project]
pub struct DialerSelectSeq<R, I>
where
R: AsyncRead + AsyncWrite,
I: Iterator,
I::Item: AsRef<[u8]>
{
pub struct DialerSelectSeq<R, I: Iterator> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a quick exploration whether we could get rid of this trait-bound as well but I don't think it is worth it. Not if we want to keep exporting a named type from multistream-select and I believe switching to impl Trait for dialer_select_proto makes the situation in rust-libp2p actually worse because we'd have more type parameters bubbling up (or would need to start boxing things once we are in libp2p-swarm).

// TODO: It would be nice if eventually N = I::Item = Protocol.
protocols: iter::Peekable<I>,
state: SeqState<R, I::Item>,
version: Version,
}

enum SeqState<R, N>
where
R: AsyncRead + AsyncWrite,
N: AsRef<[u8]>
{
enum SeqState<R, N> {
SendHeader { io: MessageIO<R>, },
SendProtocol { io: MessageIO<R>, protocol: N },
FlushProtocol { io: MessageIO<R>, protocol: N },
Expand Down Expand Up @@ -274,22 +265,13 @@ where
/// a protocol selectively by considering all supported protocols of the remote
/// "in parallel".
#[pin_project::pin_project]
pub struct DialerSelectPar<R, I>
where
R: AsyncRead + AsyncWrite,
I: Iterator,
I::Item: AsRef<[u8]>
{
pub struct DialerSelectPar<R, I: Iterator> {
protocols: I,
state: ParState<R, I::Item>,
version: Version,
}

enum ParState<R, N>
where
R: AsyncRead + AsyncWrite,
N: AsRef<[u8]>
{
enum ParState<R, N> {
SendHeader { io: MessageIO<R> },
SendProtocolsRequest { io: MessageIO<R> },
Flush { io: MessageIO<R> },
Expand Down
27 changes: 0 additions & 27 deletions misc/multistream-select/src/error.rs

This file was deleted.

12 changes: 2 additions & 10 deletions misc/multistream-select/src/listener_select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ where
/// The `Future` returned by [`listener_select_proto`] that performs a
/// multistream-select protocol negotiation on an underlying I/O stream.
#[pin_project::pin_project]
pub struct ListenerSelectFuture<R, N>
where
R: AsyncRead + AsyncWrite,
N: AsRef<[u8]>
{
pub struct ListenerSelectFuture<R, N> {
// TODO: It would be nice if eventually N = Protocol, which has a
// few more implications on the API.
protocols: SmallVec<[(N, Protocol); 8]>,
Expand All @@ -83,11 +79,7 @@ where
last_sent_na: bool,
}

enum State<R, N>
where
R: AsyncRead + AsyncWrite,
N: AsRef<[u8]>
{
enum State<R, N> {
RecvHeader { io: MessageIO<R> },
SendHeader { io: MessageIO<R> },
RecvMessage { io: MessageIO<R> },
Expand Down