mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
kmc-solid: Replace {From,Into}Inner<c_int>
impls with *RawFd
for Socket
Follows how other targets are implemented.
This commit is contained in:
parent
0dd3b25e2d
commit
cbfab81f3d
@ -378,7 +378,7 @@ macro_rules! impl_as_raw_fd {
|
||||
impl AsRawFd for net::$t {
|
||||
#[inline]
|
||||
fn as_raw_fd(&self) -> RawFd {
|
||||
*self.as_inner().socket().as_inner()
|
||||
self.as_inner().socket().as_raw_fd()
|
||||
}
|
||||
}
|
||||
)*};
|
||||
@ -391,7 +391,7 @@ macro_rules! impl_from_raw_fd {
|
||||
impl FromRawFd for net::$t {
|
||||
#[inline]
|
||||
unsafe fn from_raw_fd(fd: RawFd) -> net::$t {
|
||||
let socket = sys::net::Socket::from_inner(fd);
|
||||
let socket = unsafe { sys::net::Socket::from_raw_fd(fd) };
|
||||
net::$t::from_inner(sys_common::net::$t::from_inner(socket))
|
||||
}
|
||||
}
|
||||
@ -405,7 +405,7 @@ macro_rules! impl_into_raw_fd {
|
||||
impl IntoRawFd for net::$t {
|
||||
#[inline]
|
||||
fn into_raw_fd(self) -> RawFd {
|
||||
self.into_inner().into_socket().into_inner()
|
||||
self.into_inner().into_socket().into_raw_fd()
|
||||
}
|
||||
}
|
||||
)*};
|
||||
|
@ -5,9 +5,10 @@ use crate::{
|
||||
io::{self, BorrowedBuf, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut},
|
||||
mem,
|
||||
net::{Shutdown, SocketAddr},
|
||||
os::solid::io::{AsRawFd, FromRawFd, IntoRawFd},
|
||||
ptr, str,
|
||||
sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr},
|
||||
sys_common::{AsInner, FromInner, IntoInner},
|
||||
sys_common::IntoInner,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
@ -111,13 +112,6 @@ impl FileDesc {
|
||||
}
|
||||
}
|
||||
|
||||
impl AsInner<c_int> for FileDesc {
|
||||
#[inline]
|
||||
fn as_inner(&self) -> &c_int {
|
||||
&self.fd
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for FileDesc {
|
||||
fn drop(&mut self) {
|
||||
unsafe { netc::close(self.fd) };
|
||||
@ -454,7 +448,7 @@ impl Socket {
|
||||
pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
|
||||
let mut nonblocking = nonblocking as c_int;
|
||||
cvt(unsafe {
|
||||
netc::ioctl(*self.as_inner(), netc::FIONBIO, (&mut nonblocking) as *mut c_int as _)
|
||||
netc::ioctl(self.0.raw(), netc::FIONBIO, (&mut nonblocking) as *mut c_int as _)
|
||||
})
|
||||
.map(drop)
|
||||
}
|
||||
@ -466,25 +460,27 @@ impl Socket {
|
||||
|
||||
// This method is used by sys_common code to abstract over targets.
|
||||
pub fn as_raw(&self) -> c_int {
|
||||
*self.as_inner()
|
||||
self.0.raw()
|
||||
}
|
||||
}
|
||||
|
||||
impl AsInner<c_int> for Socket {
|
||||
impl AsRawFd for Socket {
|
||||
#[inline]
|
||||
fn as_inner(&self) -> &c_int {
|
||||
self.0.as_inner()
|
||||
fn as_raw_fd(&self) -> c_int {
|
||||
self.0.fd
|
||||
}
|
||||
}
|
||||
|
||||
impl FromInner<c_int> for Socket {
|
||||
fn from_inner(fd: c_int) -> Socket {
|
||||
impl FromRawFd for Socket {
|
||||
#[inline]
|
||||
unsafe fn from_raw_fd(fd: c_int) -> Socket {
|
||||
Socket(FileDesc::new(fd))
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoInner<c_int> for Socket {
|
||||
fn into_inner(self) -> c_int {
|
||||
impl IntoRawFd for Socket {
|
||||
#[inline]
|
||||
fn into_raw_fd(self) -> c_int {
|
||||
self.0.into_raw()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user