mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
Implement AsFd
etc. for UnixListener
.
Implement `AsFd`, `From<OwnedFd>`, and `Into<OwnedFd>` for `UnixListener`. This is a follow-up to #87329.
This commit is contained in:
parent
99b73e81b3
commit
be483ff4c1
@ -1,5 +1,5 @@
|
||||
use super::{sockaddr_un, SocketAddr, UnixStream};
|
||||
use crate::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
|
||||
use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
|
||||
use crate::path::Path;
|
||||
use crate::sys::cvt;
|
||||
use crate::sys::net::Socket;
|
||||
@ -262,6 +262,30 @@ impl IntoRawFd for UnixListener {
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "io_safety", issue = "87074")]
|
||||
impl AsFd for UnixListener {
|
||||
#[inline]
|
||||
fn as_fd(&self) -> BorrowedFd<'_> {
|
||||
self.0.as_inner().as_fd()
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "io_safety", issue = "87074")]
|
||||
impl From<OwnedFd> for UnixListener {
|
||||
#[inline]
|
||||
fn from(fd: OwnedFd) -> UnixListener {
|
||||
UnixListener(Socket::from_inner(FromInner::from_inner(OwnedFd::from(fd))))
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "io_safety", issue = "87074")]
|
||||
impl From<UnixListener> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(listener: UnixListener) -> OwnedFd {
|
||||
listener.0.into_inner().into_inner().into()
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "unix_socket", since = "1.10.0")]
|
||||
impl<'a> IntoIterator for &'a UnixListener {
|
||||
type Item = io::Result<UnixStream>;
|
||||
|
Loading…
Reference in New Issue
Block a user