1 //! `io_lifetimes` types for Windows assuming that Fd is Socket.
3 //! We can make this assumption since `rustix` supports only `rustix::net` on
6 pub use io_lifetimes
::{BorrowedSocket as BorrowedFd, OwnedSocket as OwnedFd}
;
7 #[cfg(feature = "std")]
8 pub use std
::os
::windows
::io
::RawSocket
as RawFd
;
9 pub(crate) use windows_sys
::Win32
::Networking
::WinSock
::SOCKET
as LibcFd
;
11 // Re-export the `Socket` traits so that users can implement them.
12 pub use io_lifetimes
::AsSocket
;
14 /// A version of [`AsRawFd`] for use with Winsock2 API.
16 /// [`AsRawFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/trait.AsRawFd.html
18 /// A version of [`as_raw_fd`] for use with Winsock2 API.
20 /// [`as_raw_fd`]: https://doc.rust-lang.org/stable/std/os/unix/io/trait.FromRawFd.html#tymethod.as_raw_fd
21 fn as_raw_fd(&self) -> RawFd
;
23 #[cfg(feature = "std")]
24 impl<T
: std
::os
::windows
::io
::AsRawSocket
> AsRawFd
for T
{
26 fn as_raw_fd(&self) -> RawFd
{
31 /// A version of [`IntoRawFd`] for use with Winsock2 API.
33 /// [`IntoRawFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/trait.IntoRawFd.html
35 /// A version of [`into_raw_fd`] for use with Winsock2 API.
37 /// [`into_raw_fd`]: https://doc.rust-lang.org/stable/std/os/unix/io/trait.FromRawFd.html#tymethod.into_raw_fd
38 fn into_raw_fd(self) -> RawFd
;
40 #[cfg(feature = "std")]
41 impl<T
: std
::os
::windows
::io
::IntoRawSocket
> IntoRawFd
for T
{
43 fn into_raw_fd(self) -> RawFd
{
44 self.into_raw_socket()
48 /// A version of [`FromRawFd`] for use with Winsock2 API.
50 /// [`FromRawFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/trait.FromRawFd.html
52 /// A version of [`from_raw_fd`] for use with Winsock2 API.
54 /// [`from_raw_fd`]: https://doc.rust-lang.org/stable/std/os/unix/io/trait.FromRawFd.html#tymethod.from_raw_fd
55 unsafe fn from_raw_fd(raw_fd
: RawFd
) -> Self;
57 #[cfg(feature = "std")]
58 impl<T
: std
::os
::windows
::io
::FromRawSocket
> FromRawFd
for T
{
60 unsafe fn from_raw_fd(raw_fd
: RawFd
) -> Self {
61 Self::from_raw_socket(raw_fd
)
65 /// A version of [`AsFd`] for use with Winsock2 API.
67 /// [`AsFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/trait.AsFd.html
69 /// An `as_fd` function for Winsock2, where a `Fd` is a `Socket`.
70 fn as_fd(&self) -> BorrowedFd
;
72 impl<T
: AsSocket
> AsFd
for T
{
74 fn as_fd(&self) -> BorrowedFd
{