1
1
#![ allow( deprecated) ] // Don't warn on `IntoFd` and `FromFd` impls.
2
2
3
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
3
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
4
4
use crate :: { AsFd , FromFd , IntoFd } ;
5
5
#[ cfg( windows) ]
6
6
use crate :: { AsHandle , AsSocket , FromHandle , FromSocket , IntoHandle , IntoSocket } ;
7
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
7
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
8
8
use crate :: { BorrowedFd , OwnedFd } ;
9
9
#[ cfg( windows) ]
10
10
use crate :: { BorrowedHandle , BorrowedSocket , HandleOrInvalid , OwnedHandle , OwnedSocket } ;
11
+ #[ cfg( target_os = "hermit" ) ]
12
+ use std:: os:: hermit:: io:: { AsRawFd , FromRawFd , IntoRawFd } ;
11
13
#[ cfg( unix) ]
12
14
use std:: os:: unix:: io:: { AsRawFd , FromRawFd , IntoRawFd } ;
13
15
#[ cfg( target_os = "wasi" ) ]
@@ -17,7 +19,7 @@ use std::os::windows::io::{
17
19
AsRawHandle , AsRawSocket , FromRawHandle , FromRawSocket , IntoRawHandle , IntoRawSocket ,
18
20
} ;
19
21
20
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
22
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
21
23
impl AsFd for BorrowedFd < ' _ > {
22
24
#[ inline]
23
25
fn as_fd ( & self ) -> BorrowedFd < ' _ > {
@@ -41,7 +43,7 @@ impl AsSocket for BorrowedSocket<'_> {
41
43
}
42
44
}
43
45
44
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
46
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
45
47
impl AsFd for OwnedFd {
46
48
#[ inline]
47
49
fn as_fd ( & self ) -> BorrowedFd < ' _ > {
@@ -65,7 +67,7 @@ impl AsSocket for OwnedSocket {
65
67
}
66
68
}
67
69
68
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
70
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
69
71
impl IntoFd for OwnedFd {
70
72
#[ inline]
71
73
fn into_fd ( self ) -> OwnedFd {
@@ -89,7 +91,7 @@ impl IntoSocket for OwnedSocket {
89
91
}
90
92
}
91
93
92
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
94
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
93
95
impl FromFd for OwnedFd {
94
96
#[ inline]
95
97
fn from_fd ( owned : OwnedFd ) -> Self {
@@ -129,7 +131,7 @@ impl From<OwnedHandle> for HandleOrInvalid {
129
131
}
130
132
}
131
133
132
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
134
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
133
135
impl AsFd for std:: fs:: File {
134
136
#[ inline]
135
137
fn as_fd ( & self ) -> BorrowedFd < ' _ > {
@@ -145,15 +147,15 @@ impl AsHandle for std::fs::File {
145
147
}
146
148
}
147
149
148
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
150
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
149
151
impl IntoFd for std:: fs:: File {
150
152
#[ inline]
151
153
fn into_fd ( self ) -> OwnedFd {
152
154
unsafe { OwnedFd :: from_raw_fd ( self . into_raw_fd ( ) ) }
153
155
}
154
156
}
155
157
156
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
158
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
157
159
impl From < std:: fs:: File > for OwnedFd {
158
160
#[ inline]
159
161
fn from ( owned : std:: fs:: File ) -> Self {
@@ -177,15 +179,15 @@ impl From<std::fs::File> for OwnedHandle {
177
179
}
178
180
}
179
181
180
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
182
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
181
183
impl FromFd for std:: fs:: File {
182
184
#[ inline]
183
185
fn from_fd ( owned : OwnedFd ) -> Self {
184
186
unsafe { Self :: from_raw_fd ( owned. into_raw_fd ( ) ) }
185
187
}
186
188
}
187
189
188
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
190
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
189
191
impl From < OwnedFd > for std:: fs:: File {
190
192
#[ inline]
191
193
fn from ( owned : OwnedFd ) -> Self {
@@ -209,7 +211,7 @@ impl From<OwnedHandle> for std::fs::File {
209
211
}
210
212
}
211
213
212
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
214
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
213
215
impl AsFd for std:: net:: TcpStream {
214
216
#[ inline]
215
217
fn as_fd ( & self ) -> BorrowedFd < ' _ > {
@@ -225,15 +227,15 @@ impl AsSocket for std::net::TcpStream {
225
227
}
226
228
}
227
229
228
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
230
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
229
231
impl IntoFd for std:: net:: TcpStream {
230
232
#[ inline]
231
233
fn into_fd ( self ) -> OwnedFd {
232
234
unsafe { OwnedFd :: from_raw_fd ( self . into_raw_fd ( ) ) }
233
235
}
234
236
}
235
237
236
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
238
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
237
239
impl From < std:: net:: TcpStream > for OwnedFd {
238
240
#[ inline]
239
241
fn from ( owned : std:: net:: TcpStream ) -> Self {
@@ -257,15 +259,15 @@ impl From<std::net::TcpStream> for OwnedSocket {
257
259
}
258
260
}
259
261
260
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
262
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
261
263
impl FromFd for std:: net:: TcpStream {
262
264
#[ inline]
263
265
fn from_fd ( owned : OwnedFd ) -> Self {
264
266
unsafe { Self :: from_raw_fd ( owned. into_raw_fd ( ) ) }
265
267
}
266
268
}
267
269
268
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
270
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
269
271
impl From < OwnedFd > for std:: net:: TcpStream {
270
272
#[ inline]
271
273
fn from ( owned : OwnedFd ) -> Self {
@@ -289,7 +291,7 @@ impl From<OwnedSocket> for std::net::TcpStream {
289
291
}
290
292
}
291
293
292
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
294
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
293
295
impl AsFd for std:: net:: TcpListener {
294
296
#[ inline]
295
297
fn as_fd ( & self ) -> BorrowedFd < ' _ > {
@@ -305,15 +307,15 @@ impl AsSocket for std::net::TcpListener {
305
307
}
306
308
}
307
309
308
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
310
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
309
311
impl IntoFd for std:: net:: TcpListener {
310
312
#[ inline]
311
313
fn into_fd ( self ) -> OwnedFd {
312
314
unsafe { OwnedFd :: from_raw_fd ( self . into_raw_fd ( ) ) }
313
315
}
314
316
}
315
317
316
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
318
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
317
319
impl From < std:: net:: TcpListener > for OwnedFd {
318
320
#[ inline]
319
321
fn from ( owned : std:: net:: TcpListener ) -> Self {
@@ -337,15 +339,15 @@ impl From<std::net::TcpListener> for OwnedSocket {
337
339
}
338
340
}
339
341
340
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
342
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
341
343
impl FromFd for std:: net:: TcpListener {
342
344
#[ inline]
343
345
fn from_fd ( owned : OwnedFd ) -> Self {
344
346
unsafe { Self :: from_raw_fd ( owned. into_raw_fd ( ) ) }
345
347
}
346
348
}
347
349
348
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
350
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
349
351
impl From < OwnedFd > for std:: net:: TcpListener {
350
352
#[ inline]
351
353
fn from ( owned : OwnedFd ) -> Self {
@@ -369,7 +371,7 @@ impl From<OwnedSocket> for std::net::TcpListener {
369
371
}
370
372
}
371
373
372
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
374
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
373
375
impl AsFd for std:: net:: UdpSocket {
374
376
#[ inline]
375
377
fn as_fd ( & self ) -> BorrowedFd < ' _ > {
@@ -385,15 +387,15 @@ impl AsSocket for std::net::UdpSocket {
385
387
}
386
388
}
387
389
388
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
390
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
389
391
impl IntoFd for std:: net:: UdpSocket {
390
392
#[ inline]
391
393
fn into_fd ( self ) -> OwnedFd {
392
394
unsafe { OwnedFd :: from_raw_fd ( self . into_raw_fd ( ) ) }
393
395
}
394
396
}
395
397
396
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
398
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
397
399
impl From < std:: net:: UdpSocket > for OwnedFd {
398
400
#[ inline]
399
401
fn from ( owned : std:: net:: UdpSocket ) -> Self {
@@ -417,15 +419,15 @@ impl From<std::net::UdpSocket> for OwnedSocket {
417
419
}
418
420
}
419
421
420
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
422
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
421
423
impl FromFd for std:: net:: UdpSocket {
422
424
#[ inline]
423
425
fn from_fd ( owned : OwnedFd ) -> Self {
424
426
unsafe { Self :: from_raw_fd ( owned. into_raw_fd ( ) ) }
425
427
}
426
428
}
427
429
428
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
430
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
429
431
impl From < OwnedFd > for std:: net:: UdpSocket {
430
432
#[ inline]
431
433
fn from ( owned : OwnedFd ) -> Self {
@@ -449,7 +451,7 @@ impl From<OwnedSocket> for std::net::UdpSocket {
449
451
}
450
452
}
451
453
452
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
454
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
453
455
impl AsFd for std:: io:: Stdin {
454
456
#[ inline]
455
457
fn as_fd ( & self ) -> BorrowedFd < ' _ > {
@@ -465,7 +467,7 @@ impl AsHandle for std::io::Stdin {
465
467
}
466
468
}
467
469
468
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
470
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
469
471
impl < ' a > AsFd for std:: io:: StdinLock < ' a > {
470
472
#[ inline]
471
473
fn as_fd ( & self ) -> BorrowedFd < ' _ > {
@@ -481,7 +483,7 @@ impl<'a> AsHandle for std::io::StdinLock<'a> {
481
483
}
482
484
}
483
485
484
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
486
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
485
487
impl AsFd for std:: io:: Stdout {
486
488
#[ inline]
487
489
fn as_fd ( & self ) -> BorrowedFd < ' _ > {
@@ -497,7 +499,7 @@ impl AsHandle for std::io::Stdout {
497
499
}
498
500
}
499
501
500
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
502
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
501
503
impl < ' a > AsFd for std:: io:: StdoutLock < ' a > {
502
504
#[ inline]
503
505
fn as_fd ( & self ) -> BorrowedFd < ' _ > {
@@ -513,7 +515,7 @@ impl<'a> AsHandle for std::io::StdoutLock<'a> {
513
515
}
514
516
}
515
517
516
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
518
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
517
519
impl AsFd for std:: io:: Stderr {
518
520
#[ inline]
519
521
fn as_fd ( & self ) -> BorrowedFd < ' _ > {
@@ -529,7 +531,7 @@ impl AsHandle for std::io::Stderr {
529
531
}
530
532
}
531
533
532
- #[ cfg( any( unix, target_os = "wasi" ) ) ]
534
+ #[ cfg( any( unix, target_os = "wasi" , target_os = "hermit" ) ) ]
533
535
impl < ' a > AsFd for std:: io:: StderrLock < ' a > {
534
536
#[ inline]
535
537
fn as_fd ( & self ) -> BorrowedFd < ' _ > {
0 commit comments