1
- #![ stable ( feature = "rust1 " , since = "1.0.0 " ) ]
1
+ #![ unstable ( feature = "windows_unix_domain_sockets " , issue = "none " ) ]
2
2
3
3
use core:: mem;
4
4
use core:: time:: Duration ;
@@ -14,10 +14,8 @@ use crate::sys::c::{SO_RCVTIMEO, SO_SNDTIMEO, connect, getpeername, getsockname}
14
14
use crate :: sys:: cvt;
15
15
use crate :: sys:: net:: Socket ;
16
16
17
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
18
17
pub struct UnixStream ( pub Socket ) ;
19
18
impl UnixStream {
20
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
21
19
pub fn connect < P : AsRef < Path > > ( path : P ) -> io:: Result < UnixStream > {
22
20
unsafe {
23
21
let inner = Socket :: new_unix ( ) ?;
@@ -26,64 +24,50 @@ impl UnixStream {
26
24
Ok ( UnixStream ( inner) )
27
25
}
28
26
}
29
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
30
-
31
27
pub fn local_addr ( & self ) -> io:: Result < SocketAddr > {
32
28
SocketAddr :: new ( |addr, len| unsafe { getsockname ( self . 0 . as_raw ( ) as _ , addr, len) } )
33
29
}
34
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
35
30
pub fn peer_addr ( & self ) -> io:: Result < SocketAddr > {
36
31
SocketAddr :: new ( |addr, len| unsafe { getpeername ( self . 0 . as_raw ( ) as _ , addr, len) } )
37
32
}
38
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
39
33
pub fn read_timeout ( & self ) -> io:: Result < Option < Duration > > {
40
34
self . 0 . timeout ( SO_RCVTIMEO )
41
35
}
42
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
43
36
pub fn set_nonblocking ( & self , nonblocking : bool ) -> io:: Result < ( ) > {
44
37
self . 0 . set_nonblocking ( nonblocking)
45
38
}
46
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
47
39
pub fn set_read_timeout ( & self , dur : Option < Duration > ) -> io:: Result < ( ) > {
48
40
self . 0 . set_timeout ( dur, SO_RCVTIMEO )
49
41
}
50
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
51
42
pub fn set_write_timeout ( & self , dur : Option < Duration > ) -> io:: Result < ( ) > {
52
43
self . 0 . set_timeout ( dur, SO_SNDTIMEO )
53
44
}
54
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
55
45
pub fn shutdown ( & self , how : Shutdown ) -> io:: Result < ( ) > {
56
46
self . 0 . shutdown ( how)
57
47
}
58
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
59
48
pub fn take_error ( & self ) -> io:: Result < Option < io:: Error > > {
60
49
self . 0 . take_error ( )
61
50
}
62
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
63
51
pub fn try_clone ( & self ) -> io:: Result < UnixStream > {
64
52
self . 0 . duplicate ( ) . map ( UnixStream )
65
53
}
66
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
67
54
pub fn write_timeout ( & self ) -> io:: Result < Option < Duration > > {
68
55
self . 0 . timeout ( SO_SNDTIMEO )
69
56
}
70
57
}
71
58
72
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
73
59
impl io:: Read for UnixStream {
74
60
fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
75
61
io:: Read :: read ( & mut & * self , buf)
76
62
}
77
63
}
78
64
79
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
80
65
impl < ' a > io:: Read for & ' a UnixStream {
81
66
fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
82
67
self . 0 . read ( buf)
83
68
}
84
69
}
85
70
86
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
87
71
impl io:: Write for UnixStream {
88
72
fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
89
73
io:: Write :: write ( & mut & * self , buf)
@@ -93,7 +77,6 @@ impl io::Write for UnixStream {
93
77
io:: Write :: flush ( & mut & * self )
94
78
}
95
79
}
96
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
97
80
impl < ' a > io:: Write for & ' a UnixStream {
98
81
fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
99
82
self . 0 . write_vectored ( & [ IoSlice :: new ( buf) ] )
@@ -104,28 +87,24 @@ impl<'a> io::Write for &'a UnixStream {
104
87
}
105
88
}
106
89
107
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
108
90
impl AsSocket for UnixStream {
109
91
fn as_socket ( & self ) -> BorrowedSocket {
110
92
self . 0 . as_socket ( )
111
93
}
112
94
}
113
95
114
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
115
96
impl AsRawSocket for UnixStream {
116
97
fn as_raw_socket ( & self ) -> RawSocket {
117
98
self . 0 . as_raw_socket ( )
118
99
}
119
100
}
120
101
121
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
122
102
impl FromRawSocket for UnixStream {
123
103
unsafe fn from_raw_socket ( sock : RawSocket ) -> Self {
124
104
unsafe { UnixStream ( Socket :: from_raw_socket ( sock) ) }
125
105
}
126
106
}
127
107
128
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
129
108
impl IntoRawSocket for UnixStream {
130
109
fn into_raw_socket ( self ) -> RawSocket {
131
110
let ret = self . 0 . as_raw_socket ( ) ;
0 commit comments