I believe recv(mut self) and send(mut self, mut msg: Multipart) in the request_reply sockets were designed to take self instead of &mut self so you cannot make multiple send before getting the reply and rcv before sending the reply.
However in the case of tokio::select! inside of a loop :
because recv()consumes self, the compiler won't allow for it to be used in this case.
A barbaric solution would be to spawn a task containing the recv() and use channels to communicate back and forth with the select!, however i'd rather have an appropriate method for this case.
Without wanting to alter the current structure, a quick fix for me was the create a struct RequestReply contaning both the send(&mut self, mut msg: Multipart) and the recv(&mut self)methods in the cloned repo.
I believe
recv(mut self)
andsend(mut self, mut msg: Multipart)
in the request_reply sockets were designed to take self instead of &mut self so you cannot make multiplesend
before getting the reply andrcv
before sending the reply. However in the case oftokio::select!
inside of aloop
:because
recv()
consumes self, the compiler won't allow for it to be used in this case.A barbaric solution would be to spawn a task containing the
recv()
and use channels to communicate back and forth with theselect!
, however i'd rather have an appropriate method for this case.Without wanting to alter the current structure, a quick fix for me was the create a
struct RequestReply
contaning both thesend(&mut self, mut msg: Multipart)
and therecv(&mut self)
methods in the cloned repo.