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_redox" , since = "1.27.0 " ) ]
11
+ #![ unstable ( feature = "unix_socket_redox" , reason = "new feature" , issue= "51553 ") ]
12
12
13
13
//! Unix-specific networking functionality
14
14
@@ -36,7 +36,6 @@ 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_redox" , since = "1.27.0" ) ]
40
39
#[ derive( Clone ) ]
41
40
pub struct SocketAddr ;
42
41
@@ -65,12 +64,10 @@ impl SocketAddr {
65
64
/// let addr = socket.local_addr().expect("Couldn't get local address");
66
65
/// assert_eq!(addr.as_pathname(), None);
67
66
/// ```
68
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
69
67
pub fn as_pathname ( & self ) -> Option < & Path > {
70
68
None
71
69
}
72
70
}
73
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
74
71
impl fmt:: Debug for SocketAddr {
75
72
fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
76
73
write ! ( fmt, "SocketAddr" )
@@ -91,10 +88,8 @@ impl fmt::Debug for SocketAddr {
91
88
/// stream.read_to_string(&mut response).unwrap();
92
89
/// println!("{}", response);
93
90
/// ```
94
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
95
91
pub struct UnixStream ( FileDesc ) ;
96
92
97
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
98
93
impl fmt:: Debug for UnixStream {
99
94
fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
100
95
let mut builder = fmt. debug_struct ( "UnixStream" ) ;
@@ -125,7 +120,6 @@ impl UnixStream {
125
120
/// }
126
121
/// };
127
122
/// ```
128
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
129
123
pub fn connect < P : AsRef < Path > > ( path : P ) -> io:: Result < UnixStream > {
130
124
if let Some ( s) = path. as_ref ( ) . to_str ( ) {
131
125
cvt ( syscall:: open ( format ! ( "chan:{}" , s) , syscall:: O_CLOEXEC ) )
@@ -156,7 +150,6 @@ impl UnixStream {
156
150
/// }
157
151
/// };
158
152
/// ```
159
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
160
153
pub fn pair ( ) -> io:: Result < ( UnixStream , UnixStream ) > {
161
154
let server = cvt ( syscall:: open ( "chan:" , syscall:: O_CREAT | syscall:: O_CLOEXEC ) )
162
155
. map ( FileDesc :: new) ?;
@@ -180,7 +173,6 @@ impl UnixStream {
180
173
/// let socket = UnixStream::connect("/tmp/sock").unwrap();
181
174
/// let sock_copy = socket.try_clone().expect("Couldn't clone socket");
182
175
/// ```
183
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
184
176
pub fn try_clone ( & self ) -> io:: Result < UnixStream > {
185
177
self . 0 . duplicate ( ) . map ( UnixStream )
186
178
}
@@ -195,7 +187,6 @@ impl UnixStream {
195
187
/// let socket = UnixStream::connect("/tmp/sock").unwrap();
196
188
/// let addr = socket.local_addr().expect("Couldn't get local address");
197
189
/// ```
198
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
199
190
pub fn local_addr ( & self ) -> io:: Result < SocketAddr > {
200
191
Err ( Error :: new ( ErrorKind :: Other , "UnixStream::local_addr unimplemented on redox" ) )
201
192
}
@@ -210,7 +201,6 @@ impl UnixStream {
210
201
/// let socket = UnixStream::connect("/tmp/sock").unwrap();
211
202
/// let addr = socket.peer_addr().expect("Couldn't get peer address");
212
203
/// ```
213
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
214
204
pub fn peer_addr ( & self ) -> io:: Result < SocketAddr > {
215
205
Err ( Error :: new ( ErrorKind :: Other , "UnixStream::peer_addr unimplemented on redox" ) )
216
206
}
@@ -249,7 +239,6 @@ impl UnixStream {
249
239
/// let err = result.unwrap_err();
250
240
/// assert_eq!(err.kind(), io::ErrorKind::InvalidInput)
251
241
/// ```
252
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
253
242
pub fn set_read_timeout ( & self , _timeout : Option < Duration > ) -> io:: Result < ( ) > {
254
243
Err ( Error :: new ( ErrorKind :: Other , "UnixStream::set_read_timeout unimplemented on redox" ) )
255
244
}
@@ -288,7 +277,6 @@ impl UnixStream {
288
277
/// let err = result.unwrap_err();
289
278
/// assert_eq!(err.kind(), io::ErrorKind::InvalidInput)
290
279
/// ```
291
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
292
280
pub fn set_write_timeout ( & self , _timeout : Option < Duration > ) -> io:: Result < ( ) > {
293
281
Err ( Error :: new ( ErrorKind :: Other , "UnixStream::set_write_timeout unimplemented on redox" ) )
294
282
}
@@ -305,7 +293,6 @@ impl UnixStream {
305
293
/// socket.set_read_timeout(Some(Duration::new(1, 0))).expect("Couldn't set read timeout");
306
294
/// assert_eq!(socket.read_timeout().unwrap(), Some(Duration::new(1, 0)));
307
295
/// ```
308
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
309
296
pub fn read_timeout ( & self ) -> io:: Result < Option < Duration > > {
310
297
Err ( Error :: new ( ErrorKind :: Other , "UnixStream::read_timeout unimplemented on redox" ) )
311
298
}
@@ -322,7 +309,6 @@ impl UnixStream {
322
309
/// socket.set_write_timeout(Some(Duration::new(1, 0))).expect("Couldn't set write timeout");
323
310
/// assert_eq!(socket.write_timeout().unwrap(), Some(Duration::new(1, 0)));
324
311
/// ```
325
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
326
312
pub fn write_timeout ( & self ) -> io:: Result < Option < Duration > > {
327
313
Err ( Error :: new ( ErrorKind :: Other , "UnixStream::write_timeout unimplemented on redox" ) )
328
314
}
@@ -337,7 +323,6 @@ impl UnixStream {
337
323
/// let socket = UnixStream::connect("/tmp/sock").unwrap();
338
324
/// socket.set_nonblocking(true).expect("Couldn't set nonblocking");
339
325
/// ```
340
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
341
326
pub fn set_nonblocking ( & self , nonblocking : bool ) -> io:: Result < ( ) > {
342
327
self . 0 . set_nonblocking ( nonblocking)
343
328
}
@@ -354,7 +339,6 @@ impl UnixStream {
354
339
/// println!("Got error: {:?}", err);
355
340
/// }
356
341
/// ```
357
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
358
342
pub fn take_error ( & self ) -> io:: Result < Option < io:: Error > > {
359
343
Ok ( None )
360
344
}
@@ -376,13 +360,11 @@ impl UnixStream {
376
360
/// let socket = UnixStream::connect("/tmp/sock").unwrap();
377
361
/// socket.shutdown(Shutdown::Both).expect("shutdown function failed");
378
362
/// ```
379
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
380
363
pub fn shutdown ( & self , _how : Shutdown ) -> io:: Result < ( ) > {
381
364
Err ( Error :: new ( ErrorKind :: Other , "UnixStream::shutdown unimplemented on redox" ) )
382
365
}
383
366
}
384
367
385
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
386
368
impl io:: Read for UnixStream {
387
369
fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
388
370
io:: Read :: read ( & mut & * self , buf)
@@ -394,7 +376,6 @@ impl io::Read for UnixStream {
394
376
}
395
377
}
396
378
397
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
398
379
impl < ' a > io:: Read for & ' a UnixStream {
399
380
fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
400
381
self . 0 . read ( buf)
@@ -406,7 +387,6 @@ impl<'a> io::Read for &'a UnixStream {
406
387
}
407
388
}
408
389
409
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
410
390
impl io:: Write for UnixStream {
411
391
fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
412
392
io:: Write :: write ( & mut & * self , buf)
@@ -417,7 +397,6 @@ impl io::Write for UnixStream {
417
397
}
418
398
}
419
399
420
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
421
400
impl < ' a > io:: Write for & ' a UnixStream {
422
401
fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
423
402
self . 0 . write ( buf)
@@ -428,21 +407,18 @@ impl<'a> io::Write for &'a UnixStream {
428
407
}
429
408
}
430
409
431
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
432
410
impl AsRawFd for UnixStream {
433
411
fn as_raw_fd ( & self ) -> RawFd {
434
412
self . 0 . raw ( )
435
413
}
436
414
}
437
415
438
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
439
416
impl FromRawFd for UnixStream {
440
417
unsafe fn from_raw_fd ( fd : RawFd ) -> UnixStream {
441
418
UnixStream ( FileDesc :: new ( fd) )
442
419
}
443
420
}
444
421
445
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
446
422
impl IntoRawFd for UnixStream {
447
423
fn into_raw_fd ( self ) -> RawFd {
448
424
self . 0 . into_raw ( )
@@ -477,10 +453,8 @@ impl IntoRawFd for UnixStream {
477
453
/// }
478
454
/// }
479
455
/// ```
480
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
481
456
pub struct UnixListener ( FileDesc ) ;
482
457
483
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
484
458
impl fmt:: Debug for UnixListener {
485
459
fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
486
460
let mut builder = fmt. debug_struct ( "UnixListener" ) ;
@@ -508,7 +482,6 @@ impl UnixListener {
508
482
/// }
509
483
/// };
510
484
/// ```
511
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
512
485
pub fn bind < P : AsRef < Path > > ( path : P ) -> io:: Result < UnixListener > {
513
486
if let Some ( s) = path. as_ref ( ) . to_str ( ) {
514
487
cvt ( syscall:: open ( format ! ( "chan:{}" , s) , syscall:: O_CREAT | syscall:: O_CLOEXEC ) )
@@ -542,7 +515,6 @@ impl UnixListener {
542
515
/// Err(e) => println!("accept function failed: {:?}", e),
543
516
/// }
544
517
/// ```
545
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
546
518
pub fn accept ( & self ) -> io:: Result < ( UnixStream , SocketAddr ) > {
547
519
self . 0 . duplicate_path ( b"listen" ) . map ( |fd| ( UnixStream ( fd) , SocketAddr ) )
548
520
}
@@ -562,7 +534,6 @@ impl UnixListener {
562
534
///
563
535
/// let listener_copy = listener.try_clone().expect("try_clone failed");
564
536
/// ```
565
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
566
537
pub fn try_clone ( & self ) -> io:: Result < UnixListener > {
567
538
self . 0 . duplicate ( ) . map ( UnixListener )
568
539
}
@@ -578,7 +549,6 @@ impl UnixListener {
578
549
///
579
550
/// let addr = listener.local_addr().expect("Couldn't get local address");
580
551
/// ```
581
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
582
552
pub fn local_addr ( & self ) -> io:: Result < SocketAddr > {
583
553
Err ( Error :: new ( ErrorKind :: Other , "UnixListener::local_addr unimplemented on redox" ) )
584
554
}
@@ -594,7 +564,6 @@ impl UnixListener {
594
564
///
595
565
/// listener.set_nonblocking(true).expect("Couldn't set non blocking");
596
566
/// ```
597
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
598
567
pub fn set_nonblocking ( & self , nonblocking : bool ) -> io:: Result < ( ) > {
599
568
self . 0 . set_nonblocking ( nonblocking)
600
569
}
@@ -612,7 +581,6 @@ impl UnixListener {
612
581
/// println!("Got error: {:?}", err);
613
582
/// }
614
583
/// ```
615
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
616
584
pub fn take_error ( & self ) -> io:: Result < Option < io:: Error > > {
617
585
Ok ( None )
618
586
}
@@ -648,34 +616,29 @@ impl UnixListener {
648
616
/// }
649
617
/// }
650
618
/// ```
651
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
652
619
pub fn incoming < ' a > ( & ' a self ) -> Incoming < ' a > {
653
620
Incoming { listener : self }
654
621
}
655
622
}
656
623
657
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
658
624
impl AsRawFd for UnixListener {
659
625
fn as_raw_fd ( & self ) -> RawFd {
660
626
self . 0 . raw ( )
661
627
}
662
628
}
663
629
664
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
665
630
impl FromRawFd for UnixListener {
666
631
unsafe fn from_raw_fd ( fd : RawFd ) -> UnixListener {
667
632
UnixListener ( FileDesc :: new ( fd) )
668
633
}
669
634
}
670
635
671
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
672
636
impl IntoRawFd for UnixListener {
673
637
fn into_raw_fd ( self ) -> RawFd {
674
638
self . 0 . into_raw ( )
675
639
}
676
640
}
677
641
678
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
679
642
impl < ' a > IntoIterator for & ' a UnixListener {
680
643
type Item = io:: Result < UnixStream > ;
681
644
type IntoIter = Incoming < ' a > ;
@@ -716,12 +679,10 @@ impl<'a> IntoIterator for &'a UnixListener {
716
679
/// }
717
680
/// ```
718
681
#[ derive( Debug ) ]
719
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
720
682
pub struct Incoming < ' a > {
721
683
listener : & ' a UnixListener ,
722
684
}
723
685
724
- #[ stable( feature = "unix_socket_redox" , since = "1.27.0" ) ]
725
686
impl < ' a > Iterator for Incoming < ' a > {
726
687
type Item = io:: Result < UnixStream > ;
727
688
0 commit comments