mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-10-01 12:20:39 +00:00
net: document that *Fd
traits on TcpSocket
are unix-only (#6294)
This commit is contained in:
parent
58edfc61ab
commit
eab26a662c
@ -25,6 +25,18 @@ macro_rules! cfg_windows {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Enables Unix-specific code.
|
||||||
|
/// Use this macro instead of `cfg(unix)` to generate docs properly.
|
||||||
|
macro_rules! cfg_unix {
|
||||||
|
($($item:item)*) => {
|
||||||
|
$(
|
||||||
|
#[cfg(any(all(doc, docsrs), unix))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(unix)))]
|
||||||
|
$item
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Enables unstable Windows-specific code.
|
/// Enables unstable Windows-specific code.
|
||||||
/// Use this macro instead of `cfg(windows)` to generate docs properly.
|
/// Use this macro instead of `cfg(windows)` to generate docs properly.
|
||||||
macro_rules! cfg_unstable_windows {
|
macro_rules! cfg_unstable_windows {
|
||||||
|
@ -777,22 +777,20 @@ impl fmt::Debug for TcpSocket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
cfg_unix! {
|
||||||
impl AsRawFd for TcpSocket {
|
impl AsRawFd for TcpSocket {
|
||||||
fn as_raw_fd(&self) -> RawFd {
|
fn as_raw_fd(&self) -> RawFd {
|
||||||
self.inner.as_raw_fd()
|
self.inner.as_raw_fd()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
impl AsFd for TcpSocket {
|
||||||
impl AsFd for TcpSocket {
|
|
||||||
fn as_fd(&self) -> BorrowedFd<'_> {
|
fn as_fd(&self) -> BorrowedFd<'_> {
|
||||||
unsafe { BorrowedFd::borrow_raw(self.as_raw_fd()) }
|
unsafe { BorrowedFd::borrow_raw(self.as_raw_fd()) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
impl FromRawFd for TcpSocket {
|
||||||
impl FromRawFd for TcpSocket {
|
|
||||||
/// Converts a `RawFd` to a `TcpSocket`.
|
/// Converts a `RawFd` to a `TcpSocket`.
|
||||||
///
|
///
|
||||||
/// # Notes
|
/// # Notes
|
||||||
@ -803,13 +801,13 @@ impl FromRawFd for TcpSocket {
|
|||||||
let inner = socket2::Socket::from_raw_fd(fd);
|
let inner = socket2::Socket::from_raw_fd(fd);
|
||||||
TcpSocket { inner }
|
TcpSocket { inner }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
impl IntoRawFd for TcpSocket {
|
||||||
impl IntoRawFd for TcpSocket {
|
|
||||||
fn into_raw_fd(self) -> RawFd {
|
fn into_raw_fd(self) -> RawFd {
|
||||||
self.inner.into_raw_fd()
|
self.inner.into_raw_fd()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg_windows! {
|
cfg_windows! {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user