Open dbdbc opened 10 months ago
Hi, thanks for taking the time to bring this issue to my attention and propose a solution. I'm going to play around with your changes to see if I like them. Very good point about reuse of that buffer for reads and writes, I'll have to give it some thought.
Added an async server example.
The newly added constructor was required because
read_header
already reads from the stream before the websocket upgrade even happens.Also, I fixed some stuff clippy was not satisfied with.
When looking at the
client_async
example, I noticed that the same buffer is used for rx and tx. While this might be fine in this simple case, I think in more general scenarios it could violate the contract described inframer_async::Framer::read
This should in my opinion not be in an example in this way, but to have similar implementations for
client_async
andserver_async
, I also reused the same buffer for reading and writing.Are there ways to enforce the mentioned contract? E. g. by not only storing indices into the buffer (
frame_cursor
,rx_remainder_len
), but also a&mut [u8]
in theFramer
struct? Or would this conflict with the design you have in mind?Anyway, that is not really part of this PR.
Thank you for creating this repo, and have a nice day!