From 9554f8908966ab21056b0fa51fa939f1afc83fe7 Mon Sep 17 00:00:00 2001 From: Max Inden Date: Thu, 6 May 2021 17:00:25 +0200 Subject: [PATCH 1/2] misc/multistream-select: Remove unused file error.rs --- misc/multistream-select/src/error.rs | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 misc/multistream-select/src/error.rs diff --git a/misc/multistream-select/src/error.rs b/misc/multistream-select/src/error.rs deleted file mode 100644 index 4d948de4490..00000000000 --- a/misc/multistream-select/src/error.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2017 Parity Technologies (UK) Ltd. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -//! Main `ProtocolChoiceError` error. - -pub use crate::protocol::ProtocolError; - -use std::error::Error; -use std::{fmt, io}; - From 5db7b524d193b24915de6666b3b5230ced713dd8 Mon Sep 17 00:00:00 2001 From: Max Inden Date: Thu, 6 May 2021 17:01:14 +0200 Subject: [PATCH 2/2] misc/multistream-select: Remove unnecessary trait bounds --- misc/multistream-select/src/dialer_select.rs | 26 +++---------------- .../multistream-select/src/listener_select.rs | 12 ++------- 2 files changed, 6 insertions(+), 32 deletions(-) diff --git a/misc/multistream-select/src/dialer_select.rs b/misc/multistream-select/src/dialer_select.rs index 482d31a56b3..34344bcd556 100644 --- a/misc/multistream-select/src/dialer_select.rs +++ b/misc/multistream-select/src/dialer_select.rs @@ -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 -where - R: AsyncRead + AsyncWrite, - I: Iterator, - I::Item: AsRef<[u8]> -{ +pub struct DialerSelectSeq { // TODO: It would be nice if eventually N = I::Item = Protocol. protocols: iter::Peekable, state: SeqState, version: Version, } -enum SeqState -where - R: AsyncRead + AsyncWrite, - N: AsRef<[u8]> -{ +enum SeqState { SendHeader { io: MessageIO, }, SendProtocol { io: MessageIO, protocol: N }, FlushProtocol { io: MessageIO, protocol: N }, @@ -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 -where - R: AsyncRead + AsyncWrite, - I: Iterator, - I::Item: AsRef<[u8]> -{ +pub struct DialerSelectPar { protocols: I, state: ParState, version: Version, } -enum ParState -where - R: AsyncRead + AsyncWrite, - N: AsRef<[u8]> -{ +enum ParState { SendHeader { io: MessageIO }, SendProtocolsRequest { io: MessageIO }, Flush { io: MessageIO }, diff --git a/misc/multistream-select/src/listener_select.rs b/misc/multistream-select/src/listener_select.rs index 70463fa1cfe..7cf07c5fb02 100644 --- a/misc/multistream-select/src/listener_select.rs +++ b/misc/multistream-select/src/listener_select.rs @@ -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 -where - R: AsyncRead + AsyncWrite, - N: AsRef<[u8]> -{ +pub struct ListenerSelectFuture { // TODO: It would be nice if eventually N = Protocol, which has a // few more implications on the API. protocols: SmallVec<[(N, Protocol); 8]>, @@ -83,11 +79,7 @@ where last_sent_na: bool, } -enum State -where - R: AsyncRead + AsyncWrite, - N: AsRef<[u8]> -{ +enum State { RecvHeader { io: MessageIO }, SendHeader { io: MessageIO }, RecvMessage { io: MessageIO },