diff --git a/src/lib.rs b/src/lib.rs index f6af92d7..21791034 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,14 +24,14 @@ type OutboundProtocolFn = Box Protocol + Send + 'static>; enum InboundProtocolState { - PendingSubstream(InboundProtocolFn), - PendingProtocolFn(InboundSubstream), + GotFunctionNeedSubstream(InboundProtocolFn), + GotSubstreamNeedFunction(InboundSubstream), Executing(Protocol), } enum OutboundProtocolState { - PendingSubstream(OutboundProtocolFn), - PendingProtocolFn(OutboundSubstream), + GotFunctionNeedSubstream(OutboundProtocolFn), + GotSubstreamNeedFunction(OutboundSubstream), Executing(Protocol), } @@ -145,10 +145,11 @@ where ) { match mem::replace(&mut self.state, ProtocolState::Poisoned) { ProtocolState::None => { - self.state = - ProtocolState::Inbound(InboundProtocolState::PendingProtocolFn(substream)); + self.state = ProtocolState::Inbound( + InboundProtocolState::GotSubstreamNeedFunction(substream), + ); } - ProtocolState::Inbound(InboundProtocolState::PendingSubstream(protocol_fn)) => { + ProtocolState::Inbound(InboundProtocolState::GotFunctionNeedSubstream(protocol_fn)) => { self.state = ProtocolState::Inbound(InboundProtocolState::Executing(protocol_fn(substream))); } @@ -171,10 +172,13 @@ where ) { match mem::replace(&mut self.state, ProtocolState::Poisoned) { ProtocolState::None => { - self.state = - ProtocolState::Outbound(OutboundProtocolState::PendingProtocolFn(substream)); + self.state = ProtocolState::Outbound( + OutboundProtocolState::GotSubstreamNeedFunction(substream), + ); } - ProtocolState::Outbound(OutboundProtocolState::PendingSubstream(protocol_fn)) => { + ProtocolState::Outbound(OutboundProtocolState::GotFunctionNeedSubstream( + protocol_fn, + )) => { self.state = ProtocolState::Outbound(OutboundProtocolState::Executing( protocol_fn(substream), )); @@ -197,10 +201,12 @@ where match mem::replace(&mut self.state, ProtocolState::Poisoned) { ProtocolState::None => { self.state = ProtocolState::Inbound( - InboundProtocolState::PendingSubstream(protocol_fn), + InboundProtocolState::GotFunctionNeedSubstream(protocol_fn), ); } - ProtocolState::Inbound(InboundProtocolState::PendingProtocolFn(substream)) => { + ProtocolState::Inbound(InboundProtocolState::GotSubstreamNeedFunction( + substream, + )) => { self.state = ProtocolState::Inbound(InboundProtocolState::Executing( protocol_fn(substream), )); @@ -223,10 +229,10 @@ where match mem::replace(&mut self.state, ProtocolState::Poisoned) { ProtocolState::None => { self.state = ProtocolState::Outbound( - OutboundProtocolState::PendingSubstream(protocol_fn), + OutboundProtocolState::GotFunctionNeedSubstream(protocol_fn), ); } - ProtocolState::Outbound(OutboundProtocolState::PendingProtocolFn( + ProtocolState::Outbound(OutboundProtocolState::GotSubstreamNeedFunction( substream, )) => { self.state = ProtocolState::Outbound(OutboundProtocolState::Executing(