diff --git a/msim-tokio/src/sim/net.rs b/msim-tokio/src/sim/net.rs index f28c727..fbcc0e1 100644 --- a/msim-tokio/src/sim/net.rs +++ b/msim-tokio/src/sim/net.rs @@ -4,7 +4,13 @@ use std::{ future::Future, io, net::SocketAddr as StdSocketAddr, - os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}, + os::{ + fd::AsFd, + unix::{ + io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}, + prelude::BorrowedFd, + }, + }, pin::Pin, sync::{ atomic::{AtomicBool, AtomicU32, Ordering}, @@ -734,6 +740,12 @@ impl TcpSocket { } } +impl AsFd for TcpSocket { + fn as_fd(&self) -> BorrowedFd<'_> { + self.fd.as_fd() + } +} + impl AsRawFd for TcpSocket { fn as_raw_fd(&self) -> RawFd { self.fd.as_raw_fd() @@ -756,6 +768,12 @@ impl IntoRawFd for TcpSocket { } } +impl AsFd for TcpStream { + fn as_fd(&self) -> BorrowedFd<'_> { + unimplemented!("as_fd not supported in simulator") + } +} + // To support conversion between TcpStream <-> RawFd we will need to lower the TcpState // and reading/writing operations to the net interceptor library - otherwise we can't track any // reads/writes that occur while the stream is being manipulated as a raw fd.