@@ -115,7 +115,7 @@ impl<T> RpcMessage for T where
115115/// message type, and provides some type safety when sending messages.
116116pub trait Service : Send + Sync + Debug + ' static {
117117 type WireMessage : Serialize + DeserializeOwned + Send + ' static ;
118- type Message : Send + ' static ;
118+ type Message : Send + Unpin + ' static ;
119119}
120120
121121mod sealed {
@@ -1605,17 +1605,14 @@ pub mod rpc {
16051605 + ' static ,
16061606 > ;
16071607
1608- pub trait MessageWithChannels : Send + Unpin + ' static {
1609- type WireMessage : DeserializeOwned + Send ;
1610-
1611- fn from_wire ( msg : Self :: WireMessage , rx : quinn:: RecvStream , tx : quinn:: SendStream ) -> Self ;
1612-
1613- fn forwarding_handler < S : Service < Message = Self > > (
1614- local_sender : LocalSender < S > ,
1615- ) -> Handler < Self :: WireMessage >
1616- where
1617- Self : Sized ,
1618- {
1608+ pub trait RemoteService : Service + Sized {
1609+ /// Creates a message from a wire message and a pair of quic streams.
1610+ fn from_wire (
1611+ msg : Self :: WireMessage ,
1612+ rx : quinn:: RecvStream ,
1613+ tx : quinn:: SendStream ,
1614+ ) -> Self :: Message ;
1615+ fn forwarding_handler ( local_sender : LocalSender < Self > ) -> Handler < Self :: WireMessage > {
16191616 Arc :: new ( move |msg, rx, tx| {
16201617 let msg = Self :: from_wire ( msg, rx, tx) ;
16211618 Box :: pin ( local_sender. send_raw ( msg) )
@@ -1661,13 +1658,13 @@ pub mod rpc {
16611658 }
16621659 }
16631660
1664- pub async fn read_request < M : MessageWithChannels > (
1661+ pub async fn read_request < S : RemoteService > (
16651662 connection : & quinn:: Connection ,
1666- ) -> std:: io:: Result < Option < M > > {
1663+ ) -> std:: io:: Result < Option < S :: Message > > {
16671664 Ok (
1668- match read_request_raw :: < M :: WireMessage > ( connection) . await ? {
1665+ match read_request_raw :: < S :: WireMessage > ( connection) . await ? {
16691666 None => None ,
1670- Some ( ( msg, rx, tx) ) => Some ( M :: from_wire ( msg, rx, tx) ) ,
1667+ Some ( ( msg, rx, tx) ) => Some ( S :: from_wire ( msg, rx, tx) ) ,
16711668 } ,
16721669 )
16731670 }
0 commit comments