diff options
| author | Benjamin Lamowski <benjamin.lamowski@kernkonzept.com> | 2021-10-18 13:59:36 +0200 |
|---|---|---|
| committer | Benjamin Lamowski <benjamin.lamowski@kernkonzept.com> | 2022-03-09 11:53:27 +0100 |
| commit | 997dc5899a0549ca6a6fe007ae1150ae4fccd728 (patch) | |
| tree | f2671885f64708d96c6577a8c752d3f5c7c8b931 /library/std/src | |
| parent | c0dc41f5ff00474d0c692a18330bd32f44d15d67 (diff) | |
| download | rust-997dc5899a0549ca6a6fe007ae1150ae4fccd728.tar.gz rust-997dc5899a0549ca6a6fe007ae1150ae4fccd728.zip | |
adapt L4Re network interface mock to #87329
Copy the relevant trait implementations from the Unix default.
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/sys/unix/l4re.rs | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/library/std/src/sys/unix/l4re.rs b/library/std/src/sys/unix/l4re.rs index 2bc37fc56b2..d45c51030f6 100644 --- a/library/std/src/sys/unix/l4re.rs +++ b/library/std/src/sys/unix/l4re.rs @@ -13,6 +13,7 @@ pub mod net { use crate::fmt; use crate::io::{self, IoSlice, IoSliceMut}; use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; + use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; use crate::sys::fd::FileDesc; use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::time::Duration; @@ -123,21 +124,45 @@ pub mod net { } } - impl AsInner<libc::c_int> for Socket { - fn as_inner(&self) -> &libc::c_int { - self.0.as_inner() + impl AsInner<FileDesc> for Socket { + fn as_inner(&self) -> &FileDesc { + &self.0 } } - impl FromInner<libc::c_int> for Socket { - fn from_inner(fd: libc::c_int) -> Socket { - Socket(FileDesc::new(fd)) + impl FromInner<FileDesc> for Socket { + fn from_inner(file_desc: FileDesc) -> Socket { + Socket(file_desc) } } - impl IntoInner<libc::c_int> for Socket { - fn into_inner(self) -> libc::c_int { - self.0.into_raw() + impl IntoInner<FileDesc> for Socket { + fn into_inner(self) -> FileDesc { + self.0 + } + } + + impl AsFd for Socket { + fn as_fd(&self) -> BorrowedFd<'_> { + self.0.as_fd() + } + } + + impl AsRawFd for Socket { + fn as_raw_fd(&self) -> RawFd { + self.0.as_raw_fd() + } + } + + impl IntoRawFd for Socket { + fn into_raw_fd(self) -> RawFd { + self.0.into_raw_fd() + } + } + + impl FromRawFd for Socket { + unsafe fn from_raw_fd(raw_fd: RawFd) -> Self { + Self(FromRawFd::from_raw_fd(raw_fd)) } } |
