Non blocking https://docs.rs/tungstenite/latest/tungstenite/protocol/struct.WebSocket.html#method.read_message?

For those familiar with tungstenite, is there a non blocking version of WebSocket in tungstenite::protocol - Rust ?

There is a related WebSocket in tungstenite::protocol - Rust but I'm not sure if this checks for : "is the socket still open" or "there is a full message"

In particular, the behavior I want is:

  1. if there is a full message, read it
  2. if there is not a full message, immediately return NONE

In particular, the behaviour I do NOT want is: block waiting for rest of message.

You can do it in async with FutureExt::now_or_never, but if you're using the sync interface, then probably not unless they added this separately as a dedicated feature somewhere.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.