Skip to content

Commit

Permalink
misc/multistream-select: Cleanup trait bounds and remove unused file (#…
Browse files Browse the repository at this point in the history
…2067)

* misc/multistream-select: Remove unused file error.rs

* misc/multistream-select: Remove unnecessary trait bounds
  • Loading branch information
mxinden authored May 17, 2021
1 parent 0b7ee3f commit d9f1c71
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 59 deletions.
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> {
// 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

0 comments on commit d9f1c71

Please sign in to comment.