for receiving and sending data. As both of these methods require mutable access to the whole struct, reading and writing can't happen concurrently, although I think that should be conceptually possible. I've seen a few approaches that enable this:
tokio::net::TcpStream has split() and into_split() methods that each only give you access to one half of the stream
Personally I think the third option makes for the best API, because it prevents one from having multiple concurrent readers or writers respectively, but any way to enable this would be great!
Right now, the
Uart
struct has two methodsfor receiving and sending data. As both of these methods require mutable access to the whole struct, reading and writing can't happen concurrently, although I think that should be conceptually possible. I've seen a few approaches that enable this:
serial2::SerialPort
only takes&self
for reading and writingstd::net::TcpStream
has atry_clone()
methodtokio::net::TcpStream
hassplit()
andinto_split()
methods that each only give you access to one half of the streamPersonally I think the third option makes for the best API, because it prevents one from having multiple concurrent readers or writers respectively, but any way to enable this would be great!