You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I came back to an old project and updated this crate which I still find realy nice ;) (from 0.4.2 to 0.5.1).
I noticed that you changed the behavior of Server::recv to return MessageResult which seems to be a nice upgrade compared to handling the buffer on the user side. However, now the MessageResult borrows the Server for its (the MessageResult) whole lifetime because of the internal pool. Therefore, it is not possible to Server::send while a MessageResult is returned by select!. It took me a while to identify this in my code which was looking like
enumIncoming<'a>{Webrtc(MessageResult<'a>),Channel(...),}loop{let received = tokio::select! {
msg = server.recv() => msg.map(|msg| Incoming::Webrtc(msg)),
msg = receiver.recv() => msg.map(|msg| Incoming::Channel(msg)).ok_or(...),};match received {// ...}
server.send(&some_bytes,MessageType::Binary,&client).await.unwrap()}// loop end
the compiler gave an error looking like
|
| msg = server.recv() => msg.map(|msg| Incoming::Webrtc(msg)),
| ------------------ first mutable borrow occurs here
...
| server.send(&some_bytes, MessageType::Binary, &client)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
...
| } // loop end
| - first borrow might be used here, when `received` is dropped and runs the destructor for type `Result<RtcServer::run::{closure#0}::Incoming<'_>, std::io::Error>`
For me the solution was to parse the MessageResult and to return a different owned variant such as
I came back to an old project and updated this crate which I still find realy nice ;) (from 0.4.2 to 0.5.1).
I noticed that you changed the behavior of
Server::recv
to returnMessageResult
which seems to be a nice upgrade compared to handling the buffer on the user side. However, now theMessageResult
borrows theServer
for its (theMessageResult
) whole lifetime because of the internal pool. Therefore, it is not possible toServer::send
while aMessageResult
is returned byselect!
. It took me a while to identify this in my code which was looking likethe compiler gave an error looking like
For me the solution was to parse the
MessageResult
and to return a different owned variant such asI am not asking for any changes, just putting this here because somebody might run into the same issue ;)
The text was updated successfully, but these errors were encountered: