Skip to content

Commit

Permalink
Remove Sync bound from RequestResponseCodec::Protocol.
Browse files Browse the repository at this point in the history
Apparently the compiler just needs some help with the scope
of borrows, which is unfortunate.
  • Loading branch information
romanb committed Jun 26, 2020
1 parent f964bbc commit fa2ee41
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion protocols/request-response/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use std::io;
/// protocol family and how they are encoded / decoded on an I/O stream.
pub trait RequestResponseCodec {
/// The type of protocol(s) or protocol versions being negotiated.
type Protocol: ProtocolName + Send + Sync + Clone;
type Protocol: ProtocolName + Send + Clone;
/// The type of inbound and outbound requests.
type Request: Send;
/// The type of inbound and outbound responses.
Expand Down
12 changes: 8 additions & 4 deletions protocols/request-response/src/handler/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@ where

fn upgrade_inbound(mut self, mut io: NegotiatedSubstream, protocol: Self::Info) -> Self::Future {
async move {
let request = self.codec.read_request(&protocol, &mut io).await?;
let read = self.codec.read_request(&protocol, &mut io);
let request = read.await?;
if let Ok(()) = self.request_sender.send(request) {
if let Ok(response) = self.response_receiver.await {
self.codec.write_response(&protocol, &mut io, response).await?;
let write = self.codec.write_response(&protocol, &mut io, response);
write.await?;
}
}
Ok(())
Expand Down Expand Up @@ -152,8 +154,10 @@ where

fn upgrade_outbound(mut self, mut io: NegotiatedSubstream, protocol: Self::Info) -> Self::Future {
async move {
self.codec.write_request(&protocol, &mut io, self.request).await?;
let response = self.codec.read_response(&protocol, &mut io).await?;
let write = self.codec.write_request(&protocol, &mut io, self.request);
write.await?;
let read = self.codec.read_response(&protocol, &mut io);
let response = read.await?;
Ok(response)
}.boxed()
}
Expand Down

0 comments on commit fa2ee41

Please sign in to comment.