@@ -9,7 +9,6 @@ use crate::marker::PhantomData;
99use crate :: mem;
1010use crate :: mem:: forget;
1111use crate :: sys;
12- use crate :: sys:: c;
1312#[ cfg( not( target_vendor = "uwp" ) ) ]
1413use crate :: sys:: cvt;
1514
@@ -76,7 +75,7 @@ impl BorrowedSocket<'_> {
7675 #[ rustc_const_stable( feature = "io_safety" , since = "1.63.0" ) ]
7776 #[ stable( feature = "io_safety" , since = "1.63.0" ) ]
7877 pub const unsafe fn borrow_raw ( socket : RawSocket ) -> Self {
79- assert ! ( socket != c:: INVALID_SOCKET as RawSocket ) ;
78+ assert ! ( socket != sys :: c:: INVALID_SOCKET as RawSocket ) ;
8079 Self { socket, _phantom : PhantomData }
8180 }
8281}
@@ -94,7 +93,11 @@ impl OwnedSocket {
9493 #[ cfg( not( target_vendor = "uwp" ) ) ]
9594 pub ( crate ) fn set_no_inherit ( & self ) -> io:: Result < ( ) > {
9695 cvt ( unsafe {
97- c:: SetHandleInformation ( self . as_raw_socket ( ) as c:: HANDLE , c:: HANDLE_FLAG_INHERIT , 0 )
96+ sys:: c:: SetHandleInformation (
97+ self . as_raw_socket ( ) as sys:: c:: HANDLE ,
98+ sys:: c:: HANDLE_FLAG_INHERIT ,
99+ 0 ,
100+ )
98101 } )
99102 . map ( drop)
100103 }
@@ -110,43 +113,47 @@ impl BorrowedSocket<'_> {
110113 /// object as the existing `BorrowedSocket` instance.
111114 #[ stable( feature = "io_safety" , since = "1.63.0" ) ]
112115 pub fn try_clone_to_owned ( & self ) -> io:: Result < OwnedSocket > {
113- let mut info = unsafe { mem:: zeroed :: < c:: WSAPROTOCOL_INFOW > ( ) } ;
116+ let mut info = unsafe { mem:: zeroed :: < sys :: c:: WSAPROTOCOL_INFOW > ( ) } ;
114117 let result = unsafe {
115- c:: WSADuplicateSocketW ( self . as_raw_socket ( ) , c:: GetCurrentProcessId ( ) , & mut info)
118+ sys:: c:: WSADuplicateSocketW (
119+ self . as_raw_socket ( ) ,
120+ sys:: c:: GetCurrentProcessId ( ) ,
121+ & mut info,
122+ )
116123 } ;
117124 sys:: net:: cvt ( result) ?;
118125 let socket = unsafe {
119- c:: WSASocketW (
126+ sys :: c:: WSASocketW (
120127 info. iAddressFamily ,
121128 info. iSocketType ,
122129 info. iProtocol ,
123130 & mut info,
124131 0 ,
125- c:: WSA_FLAG_OVERLAPPED | c:: WSA_FLAG_NO_HANDLE_INHERIT ,
132+ sys :: c:: WSA_FLAG_OVERLAPPED | sys :: c:: WSA_FLAG_NO_HANDLE_INHERIT ,
126133 )
127134 } ;
128135
129- if socket != c:: INVALID_SOCKET {
136+ if socket != sys :: c:: INVALID_SOCKET {
130137 unsafe { Ok ( OwnedSocket :: from_raw_socket ( socket) ) }
131138 } else {
132- let error = unsafe { c:: WSAGetLastError ( ) } ;
139+ let error = unsafe { sys :: c:: WSAGetLastError ( ) } ;
133140
134- if error != c:: WSAEPROTOTYPE && error != c:: WSAEINVAL {
141+ if error != sys :: c:: WSAEPROTOTYPE && error != sys :: c:: WSAEINVAL {
135142 return Err ( io:: Error :: from_raw_os_error ( error) ) ;
136143 }
137144
138145 let socket = unsafe {
139- c:: WSASocketW (
146+ sys :: c:: WSASocketW (
140147 info. iAddressFamily ,
141148 info. iSocketType ,
142149 info. iProtocol ,
143150 & mut info,
144151 0 ,
145- c:: WSA_FLAG_OVERLAPPED ,
152+ sys :: c:: WSA_FLAG_OVERLAPPED ,
146153 )
147154 } ;
148155
149- if socket == c:: INVALID_SOCKET {
156+ if socket == sys :: c:: INVALID_SOCKET {
150157 return Err ( last_error ( ) ) ;
151158 }
152159
@@ -161,7 +168,7 @@ impl BorrowedSocket<'_> {
161168
162169/// Returns the last error from the Windows socket interface.
163170fn last_error ( ) -> io:: Error {
164- io:: Error :: from_raw_os_error ( unsafe { c:: WSAGetLastError ( ) } )
171+ io:: Error :: from_raw_os_error ( unsafe { sys :: c:: WSAGetLastError ( ) } )
165172}
166173
167174#[ stable( feature = "io_safety" , since = "1.63.0" ) ]
@@ -194,7 +201,7 @@ impl IntoRawSocket for OwnedSocket {
194201impl FromRawSocket for OwnedSocket {
195202 #[ inline]
196203 unsafe fn from_raw_socket ( socket : RawSocket ) -> Self {
197- debug_assert_ne ! ( socket, c:: INVALID_SOCKET as RawSocket ) ;
204+ debug_assert_ne ! ( socket, sys :: c:: INVALID_SOCKET as RawSocket ) ;
198205 Self { socket }
199206 }
200207}
@@ -204,7 +211,7 @@ impl Drop for OwnedSocket {
204211 #[ inline]
205212 fn drop ( & mut self ) {
206213 unsafe {
207- let _ = c:: closesocket ( self . socket ) ;
214+ let _ = sys :: c:: closesocket ( self . socket ) ;
208215 }
209216 }
210217}
0 commit comments