Closed mcches closed 1 year ago
Is your feature request related to a problem? Please describe.
Yes, turmoil::net::TcpStream does not behave like tokio::net::TcpStream.
turmoil::net::TcpStream
tokio::net::TcpStream
AsyncRead is broken if the supplied buf does not have capacity for the next message.
AsyncRead
#[test] fn read_buf_smaller_than_msg() -> Result { let mut sim = Builder::new().build(); sim.client("server", async { let listener = bind().await?; let (mut s, _) = listener.accept().await?; s.write_u64(1234).await?; Ok(()) }); sim.client("client", async { let mut s = TcpStream::connect(("server", PORT)).await?; let mut buf = [0; 1]; // panic!: buf.len() must fit in remaining() let _r = s.read(&mut buf).await?; Ok(()) }); sim.run() }
See: https://github.com/tokio-rs/turmoil/blob/2d0fadde00de4011621607b933eb170f723111a3/src/net/tcp/stream.rs#L137
Describe the solution you'd like
Align turmoil with tokio::net.
turmoil
tokio::net
Is your feature request related to a problem? Please describe.
Yes,
turmoil::net::TcpStream
does not behave liketokio::net::TcpStream
.AsyncRead
is broken if the supplied buf does not have capacity for the next message.See: https://github.com/tokio-rs/turmoil/blob/2d0fadde00de4011621607b933eb170f723111a3/src/net/tcp/stream.rs#L137
Describe the solution you'd like
Align
turmoil
withtokio::net
.