io: update to Mio 0.7 (#2893)

This also makes Mio an implementation detail, removing it from the
public API.

This is based on #1767.
This commit is contained in:
Carl Lerche
2020-10-02 13:54:00 -07:00
committed by GitHub
parent 7ec6d88b21
commit 1e585ccb51
19 changed files with 477 additions and 589 deletions
+27
View File
@@ -44,6 +44,33 @@ async fn echo() -> io::Result<()> {
Ok(())
}
#[tokio::test]
async fn echo_from() -> io::Result<()> {
let dir = tempfile::tempdir().unwrap();
let server_path = dir.path().join("server.sock");
let client_path = dir.path().join("client.sock");
let server_socket = UnixDatagram::bind(server_path.clone())?;
tokio::spawn(async move {
if let Err(e) = echo_server(server_socket).await {
eprintln!("Error in echo server: {}", e);
}
});
{
let socket = UnixDatagram::bind(&client_path).unwrap();
socket.connect(&server_path)?;
socket.send(b"ECHO").await?;
let mut recv_buf = [0u8; 16];
let (len, addr) = socket.recv_from(&mut recv_buf[..]).await?;
assert_eq!(&recv_buf[..len], b"ECHO");
assert_eq!(addr.as_pathname(), Some(server_path.as_path()));
}
Ok(())
}
// Even though we use sync non-blocking io we still need a reactor.
#[tokio::test]
async fn try_send_recv_never_block() -> io::Result<()> {