8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
- #![ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
11
+ #![ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
12
12
13
13
//! Unix-specific networking functionality
14
14
@@ -36,7 +36,7 @@ use sys::{cvt, fd::FileDesc, syscall};
36
36
/// };
37
37
/// let addr = socket.local_addr().expect("Couldn't get local address");
38
38
/// ```
39
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
39
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
40
40
#[ derive( Clone ) ]
41
41
pub struct SocketAddr ;
42
42
@@ -65,12 +65,12 @@ impl SocketAddr {
65
65
/// let addr = socket.local_addr().expect("Couldn't get local address");
66
66
/// assert_eq!(addr.as_pathname(), None);
67
67
/// ```
68
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
68
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
69
69
pub fn as_pathname ( & self ) -> Option < & Path > {
70
70
None
71
71
}
72
72
}
73
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
73
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
74
74
impl fmt:: Debug for SocketAddr {
75
75
fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
76
76
write ! ( fmt, "SocketAddr" )
@@ -91,10 +91,10 @@ impl fmt::Debug for SocketAddr {
91
91
/// stream.read_to_string(&mut response).unwrap();
92
92
/// println!("{}", response);
93
93
/// ```
94
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
94
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
95
95
pub struct UnixStream ( FileDesc ) ;
96
96
97
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
97
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
98
98
impl fmt:: Debug for UnixStream {
99
99
fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
100
100
let mut builder = fmt. debug_struct ( "UnixStream" ) ;
@@ -125,7 +125,7 @@ impl UnixStream {
125
125
/// }
126
126
/// };
127
127
/// ```
128
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
128
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
129
129
pub fn connect < P : AsRef < Path > > ( path : P ) -> io:: Result < UnixStream > {
130
130
if let Some ( s) = path. as_ref ( ) . to_str ( ) {
131
131
cvt ( syscall:: open ( format ! ( "chan:{}" , s) , syscall:: O_CLOEXEC ) )
@@ -156,7 +156,7 @@ impl UnixStream {
156
156
/// }
157
157
/// };
158
158
/// ```
159
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
159
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
160
160
pub fn pair ( ) -> io:: Result < ( UnixStream , UnixStream ) > {
161
161
let server = cvt ( syscall:: open ( "chan:" , syscall:: O_CREAT | syscall:: O_CLOEXEC ) )
162
162
. map ( FileDesc :: new) ?;
@@ -180,7 +180,7 @@ impl UnixStream {
180
180
/// let socket = UnixStream::connect("/tmp/sock").unwrap();
181
181
/// let sock_copy = socket.try_clone().expect("Couldn't clone socket");
182
182
/// ```
183
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
183
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
184
184
pub fn try_clone ( & self ) -> io:: Result < UnixStream > {
185
185
self . 0 . duplicate ( ) . map ( UnixStream )
186
186
}
@@ -195,7 +195,7 @@ impl UnixStream {
195
195
/// let socket = UnixStream::connect("/tmp/sock").unwrap();
196
196
/// let addr = socket.local_addr().expect("Couldn't get local address");
197
197
/// ```
198
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
198
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
199
199
pub fn local_addr ( & self ) -> io:: Result < SocketAddr > {
200
200
Err ( Error :: new ( ErrorKind :: Other , "UnixStream::local_addr unimplemented on redox" ) )
201
201
}
@@ -210,7 +210,7 @@ impl UnixStream {
210
210
/// let socket = UnixStream::connect("/tmp/sock").unwrap();
211
211
/// let addr = socket.peer_addr().expect("Couldn't get peer address");
212
212
/// ```
213
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
213
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
214
214
pub fn peer_addr ( & self ) -> io:: Result < SocketAddr > {
215
215
Err ( Error :: new ( ErrorKind :: Other , "UnixStream::peer_addr unimplemented on redox" ) )
216
216
}
@@ -249,7 +249,7 @@ impl UnixStream {
249
249
/// let err = result.unwrap_err();
250
250
/// assert_eq!(err.kind(), io::ErrorKind::InvalidInput)
251
251
/// ```
252
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
252
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
253
253
pub fn set_read_timeout ( & self , _timeout : Option < Duration > ) -> io:: Result < ( ) > {
254
254
Err ( Error :: new ( ErrorKind :: Other , "UnixStream::set_read_timeout unimplemented on redox" ) )
255
255
}
@@ -288,7 +288,7 @@ impl UnixStream {
288
288
/// let err = result.unwrap_err();
289
289
/// assert_eq!(err.kind(), io::ErrorKind::InvalidInput)
290
290
/// ```
291
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
291
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
292
292
pub fn set_write_timeout ( & self , _timeout : Option < Duration > ) -> io:: Result < ( ) > {
293
293
Err ( Error :: new ( ErrorKind :: Other , "UnixStream::set_write_timeout unimplemented on redox" ) )
294
294
}
@@ -305,7 +305,7 @@ impl UnixStream {
305
305
/// socket.set_read_timeout(Some(Duration::new(1, 0))).expect("Couldn't set read timeout");
306
306
/// assert_eq!(socket.read_timeout().unwrap(), Some(Duration::new(1, 0)));
307
307
/// ```
308
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
308
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
309
309
pub fn read_timeout ( & self ) -> io:: Result < Option < Duration > > {
310
310
Err ( Error :: new ( ErrorKind :: Other , "UnixStream::read_timeout unimplemented on redox" ) )
311
311
}
@@ -322,7 +322,7 @@ impl UnixStream {
322
322
/// socket.set_write_timeout(Some(Duration::new(1, 0))).expect("Couldn't set write timeout");
323
323
/// assert_eq!(socket.write_timeout().unwrap(), Some(Duration::new(1, 0)));
324
324
/// ```
325
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
325
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
326
326
pub fn write_timeout ( & self ) -> io:: Result < Option < Duration > > {
327
327
Err ( Error :: new ( ErrorKind :: Other , "UnixStream::write_timeout unimplemented on redox" ) )
328
328
}
@@ -337,7 +337,7 @@ impl UnixStream {
337
337
/// let socket = UnixStream::connect("/tmp/sock").unwrap();
338
338
/// socket.set_nonblocking(true).expect("Couldn't set nonblocking");
339
339
/// ```
340
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
340
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
341
341
pub fn set_nonblocking ( & self , nonblocking : bool ) -> io:: Result < ( ) > {
342
342
self . 0 . set_nonblocking ( nonblocking)
343
343
}
@@ -354,7 +354,7 @@ impl UnixStream {
354
354
/// println!("Got error: {:?}", err);
355
355
/// }
356
356
/// ```
357
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
357
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
358
358
pub fn take_error ( & self ) -> io:: Result < Option < io:: Error > > {
359
359
Ok ( None )
360
360
}
@@ -376,13 +376,13 @@ impl UnixStream {
376
376
/// let socket = UnixStream::connect("/tmp/sock").unwrap();
377
377
/// socket.shutdown(Shutdown::Both).expect("shutdown function failed");
378
378
/// ```
379
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
379
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
380
380
pub fn shutdown ( & self , _how : Shutdown ) -> io:: Result < ( ) > {
381
381
Err ( Error :: new ( ErrorKind :: Other , "UnixStream::shutdown unimplemented on redox" ) )
382
382
}
383
383
}
384
384
385
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
385
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
386
386
impl io:: Read for UnixStream {
387
387
fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
388
388
io:: Read :: read ( & mut & * self , buf)
@@ -394,7 +394,7 @@ impl io::Read for UnixStream {
394
394
}
395
395
}
396
396
397
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
397
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
398
398
impl < ' a > io:: Read for & ' a UnixStream {
399
399
fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
400
400
self . 0 . read ( buf)
@@ -406,7 +406,7 @@ impl<'a> io::Read for &'a UnixStream {
406
406
}
407
407
}
408
408
409
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
409
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
410
410
impl io:: Write for UnixStream {
411
411
fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
412
412
io:: Write :: write ( & mut & * self , buf)
@@ -417,7 +417,7 @@ impl io::Write for UnixStream {
417
417
}
418
418
}
419
419
420
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
420
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
421
421
impl < ' a > io:: Write for & ' a UnixStream {
422
422
fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
423
423
self . 0 . write ( buf)
@@ -428,21 +428,21 @@ impl<'a> io::Write for &'a UnixStream {
428
428
}
429
429
}
430
430
431
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
431
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
432
432
impl AsRawFd for UnixStream {
433
433
fn as_raw_fd ( & self ) -> RawFd {
434
434
self . 0 . raw ( )
435
435
}
436
436
}
437
437
438
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
438
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
439
439
impl FromRawFd for UnixStream {
440
440
unsafe fn from_raw_fd ( fd : RawFd ) -> UnixStream {
441
441
UnixStream ( FileDesc :: new ( fd) )
442
442
}
443
443
}
444
444
445
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
445
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
446
446
impl IntoRawFd for UnixStream {
447
447
fn into_raw_fd ( self ) -> RawFd {
448
448
self . 0 . into_raw ( )
@@ -477,10 +477,10 @@ impl IntoRawFd for UnixStream {
477
477
/// }
478
478
/// }
479
479
/// ```
480
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
480
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
481
481
pub struct UnixListener ( FileDesc ) ;
482
482
483
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
483
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
484
484
impl fmt:: Debug for UnixListener {
485
485
fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
486
486
let mut builder = fmt. debug_struct ( "UnixListener" ) ;
@@ -508,7 +508,7 @@ impl UnixListener {
508
508
/// }
509
509
/// };
510
510
/// ```
511
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
511
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
512
512
pub fn bind < P : AsRef < Path > > ( path : P ) -> io:: Result < UnixListener > {
513
513
if let Some ( s) = path. as_ref ( ) . to_str ( ) {
514
514
cvt ( syscall:: open ( format ! ( "chan:{}" , s) , syscall:: O_CREAT | syscall:: O_CLOEXEC ) )
@@ -542,7 +542,7 @@ impl UnixListener {
542
542
/// Err(e) => println!("accept function failed: {:?}", e),
543
543
/// }
544
544
/// ```
545
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
545
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
546
546
pub fn accept ( & self ) -> io:: Result < ( UnixStream , SocketAddr ) > {
547
547
self . 0 . duplicate_path ( b"listen" ) . map ( |fd| ( UnixStream ( fd) , SocketAddr ) )
548
548
}
@@ -562,7 +562,7 @@ impl UnixListener {
562
562
///
563
563
/// let listener_copy = listener.try_clone().expect("try_clone failed");
564
564
/// ```
565
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
565
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
566
566
pub fn try_clone ( & self ) -> io:: Result < UnixListener > {
567
567
self . 0 . duplicate ( ) . map ( UnixListener )
568
568
}
@@ -578,7 +578,7 @@ impl UnixListener {
578
578
///
579
579
/// let addr = listener.local_addr().expect("Couldn't get local address");
580
580
/// ```
581
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
581
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
582
582
pub fn local_addr ( & self ) -> io:: Result < SocketAddr > {
583
583
Err ( Error :: new ( ErrorKind :: Other , "UnixListener::local_addr unimplemented on redox" ) )
584
584
}
@@ -594,7 +594,7 @@ impl UnixListener {
594
594
///
595
595
/// listener.set_nonblocking(true).expect("Couldn't set non blocking");
596
596
/// ```
597
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
597
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
598
598
pub fn set_nonblocking ( & self , nonblocking : bool ) -> io:: Result < ( ) > {
599
599
self . 0 . set_nonblocking ( nonblocking)
600
600
}
@@ -612,7 +612,7 @@ impl UnixListener {
612
612
/// println!("Got error: {:?}", err);
613
613
/// }
614
614
/// ```
615
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
615
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
616
616
pub fn take_error ( & self ) -> io:: Result < Option < io:: Error > > {
617
617
Ok ( None )
618
618
}
@@ -648,34 +648,34 @@ impl UnixListener {
648
648
/// }
649
649
/// }
650
650
/// ```
651
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
651
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
652
652
pub fn incoming < ' a > ( & ' a self ) -> Incoming < ' a > {
653
653
Incoming { listener : self }
654
654
}
655
655
}
656
656
657
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
657
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
658
658
impl AsRawFd for UnixListener {
659
659
fn as_raw_fd ( & self ) -> RawFd {
660
660
self . 0 . raw ( )
661
661
}
662
662
}
663
663
664
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
664
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
665
665
impl FromRawFd for UnixListener {
666
666
unsafe fn from_raw_fd ( fd : RawFd ) -> UnixListener {
667
667
UnixListener ( FileDesc :: new ( fd) )
668
668
}
669
669
}
670
670
671
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
671
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
672
672
impl IntoRawFd for UnixListener {
673
673
fn into_raw_fd ( self ) -> RawFd {
674
674
self . 0 . into_raw ( )
675
675
}
676
676
}
677
677
678
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
678
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
679
679
impl < ' a > IntoIterator for & ' a UnixListener {
680
680
type Item = io:: Result < UnixStream > ;
681
681
type IntoIter = Incoming < ' a > ;
@@ -716,12 +716,12 @@ impl<'a> IntoIterator for &'a UnixListener {
716
716
/// }
717
717
/// ```
718
718
#[ derive( Debug ) ]
719
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
719
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
720
720
pub struct Incoming < ' a > {
721
721
listener : & ' a UnixListener ,
722
722
}
723
723
724
- #[ stable( feature = "unix_socket " , since = "1.10 .0" ) ]
724
+ #[ stable( feature = "unix_socket_redox " , since = "1.27 .0" ) ]
725
725
impl < ' a > Iterator for Incoming < ' a > {
726
726
type Item = io:: Result < UnixStream > ;
727
727
0 commit comments