elaborate 1.2.0

Wrappers for standard library functions and types to produce more elaborate error messages
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
// This file was automatically generated by `elaborate`.
// https://github.com/trailofbits/elaborate

#[allow(unused_imports)]
use anyhow::Context;


pub trait BufReadContext: std :: io :: BufRead {
/// Checks if there is any data left to be `read`.
/// 
/// This function may fill the buffer to check for data,
/// so this function returns `Result<bool>`, not `bool`.
/// 
/// The default implementation calls `fill_buf` and checks that the
/// returned slice is empty (which means that there is no data left,
/// since EOF is reached).
/// 
/// # Errors
/// 
/// This function will return an I/O error if a `Read` method was called, but returned an error.
/// 
/// Examples
/// 
/// ```
/// #![feature(buf_read_has_data_left)]
/// use std::io;
/// use std::io::prelude::*;
/// 
/// let stdin = io::stdin();
/// let mut stdin = stdin.lock();
/// 
/// while stdin.has_data_left()? {
///     let mut line = String::new();
///     stdin.read_line(&mut line)?;
///     // work with line
///     println!("{line:?}");
/// }
/// # std::io::Result::Ok(())
/// ```
#[cfg(feature = "buf_read_has_data_left")]
fn has_data_left_wc ( & mut self ) -> crate :: rewrite_output_type ! ( std :: io :: Result < bool > ) {
    < Self as :: std :: io :: BufRead > :: has_data_left(self)
        .with_context(|| crate::call_failed!(Some(self), "has_data_left"))
}
/// Reads all bytes into `buf` until the delimiter `byte` or EOF is reached.
/// 
/// This function will read bytes from the underlying stream until the
/// delimiter or EOF is found. Once found, all bytes up to, and including,
/// the delimiter (if found) will be appended to `buf`.
/// 
/// If successful, this function will return the total number of bytes read.
/// 
/// This function is blocking and should be used carefully: it is possible for
/// an attacker to continuously send bytes without ever sending the delimiter
/// or EOF.
/// 
/// # Errors
/// 
/// This function will ignore all instances of [`ErrorKind::Interrupted`] and
/// will otherwise return any errors returned by [`fill_buf`].
/// 
/// If an I/O error is encountered then all bytes read so far will be
/// present in `buf` and its length will have been adjusted appropriately.
/// 
/// [`fill_buf`]: BufRead::fill_buf
/// 
/// # Examples
/// 
/// [`std::io::Cursor`][`Cursor`] is a type that implements `BufRead`. In
/// this example, we use [`Cursor`] to read all the bytes in a byte slice
/// in hyphen delimited segments:
/// 
/// ```
/// use std::io::{self, BufRead};
/// 
/// let mut cursor = io::Cursor::new(b"lorem-ipsum");
/// let mut buf = vec![];
/// 
/// // cursor is at 'l'
/// let num_bytes = cursor.read_until(b'-', &mut buf)
///     .expect("reading from cursor won't fail");
/// assert_eq!(num_bytes, 6);
/// assert_eq!(buf, b"lorem-");
/// buf.clear();
/// 
/// // cursor is at 'i'
/// let num_bytes = cursor.read_until(b'-', &mut buf)
///     .expect("reading from cursor won't fail");
/// assert_eq!(num_bytes, 5);
/// assert_eq!(buf, b"ipsum");
/// buf.clear();
/// 
/// // cursor is at EOF
/// let num_bytes = cursor.read_until(b'-', &mut buf)
///     .expect("reading from cursor won't fail");
/// assert_eq!(num_bytes, 0);
/// assert_eq!(buf, b"");
/// ```
fn read_until_wc ( & mut self , byte : u8 , buf : & mut std :: vec :: Vec < u8 > ) -> crate :: rewrite_output_type ! ( std :: io :: Result < usize > ) {
    < Self as :: std :: io :: BufRead > :: read_until(self, byte, buf)
        .with_context(|| crate::call_failed!(Some(self), "read_until", byte, buf))
}
/// Reads all bytes until a newline (the `0xA` byte) is reached, and append
/// them to the provided `String` buffer.
/// 
/// Previous content of the buffer will be preserved. To avoid appending to
/// the buffer, you need to [`clear`] it first.
/// 
/// This function will read bytes from the underlying stream until the
/// newline delimiter (the `0xA` byte) or EOF is found. Once found, all bytes
/// up to, and including, the delimiter (if found) will be appended to
/// `buf`.
/// 
/// If successful, this function will return the total number of bytes read.
/// 
/// If this function returns [`Ok(0)`], the stream has reached EOF.
/// 
/// This function is blocking and should be used carefully: it is possible for
/// an attacker to continuously send bytes without ever sending a newline
/// or EOF. You can use [`take`] to limit the maximum number of bytes read.
/// 
/// [`Ok(0)`]: Ok
/// [`clear`]: String::clear
/// [`take`]: crate::io::Read::take
/// 
/// # Errors
/// 
/// This function has the same error semantics as [`read_until`] and will
/// also return an error if the read bytes are not valid UTF-8. If an I/O
/// error is encountered then `buf` may contain some bytes already read in
/// the event that all data read so far was valid UTF-8.
/// 
/// [`read_until`]: BufRead::read_until
/// 
/// # Examples
/// 
/// [`std::io::Cursor`][`Cursor`] is a type that implements `BufRead`. In
/// this example, we use [`Cursor`] to read all the lines in a byte slice:
/// 
/// ```
/// use std::io::{self, BufRead};
/// 
/// let mut cursor = io::Cursor::new(b"foo\nbar");
/// let mut buf = String::new();
/// 
/// // cursor is at 'f'
/// let num_bytes = cursor.read_line(&mut buf)
///     .expect("reading from cursor won't fail");
/// assert_eq!(num_bytes, 4);
/// assert_eq!(buf, "foo\n");
/// buf.clear();
/// 
/// // cursor is at 'b'
/// let num_bytes = cursor.read_line(&mut buf)
///     .expect("reading from cursor won't fail");
/// assert_eq!(num_bytes, 3);
/// assert_eq!(buf, "bar");
/// buf.clear();
/// 
/// // cursor is at EOF
/// let num_bytes = cursor.read_line(&mut buf)
///     .expect("reading from cursor won't fail");
/// assert_eq!(num_bytes, 0);
/// assert_eq!(buf, "");
/// ```
fn read_line_wc ( & mut self , buf : & mut std :: string :: String ) -> crate :: rewrite_output_type ! ( std :: io :: Result < usize > ) {
    < Self as :: std :: io :: BufRead > :: read_line(self, buf)
        .with_context(|| crate::call_failed!(Some(self), "read_line", buf))
}
/// Returns the contents of the internal buffer, filling it with more data, via `Read` methods, if empty.
/// 
/// This is a lower-level method and is meant to be used together with [`consume`],
/// which can be used to mark bytes that should not be returned by subsequent calls to `read`.
/// 
/// [`consume`]: BufRead::consume
/// 
/// Returns an empty buffer when the stream has reached EOF.
/// 
/// # Errors
/// 
/// This function will return an I/O error if a `Read` method was called, but returned an error.
/// 
/// # Examples
/// 
/// A locked standard input implements `BufRead`:
/// 
/// ```no_run
/// use std::io;
/// use std::io::prelude::*;
/// 
/// let stdin = io::stdin();
/// let mut stdin = stdin.lock();
/// 
/// let buffer = stdin.fill_buf()?;
/// 
/// // work with buffer
/// println!("{buffer:?}");
/// 
/// // mark the bytes we worked with as read
/// let length = buffer.len();
/// stdin.consume(length);
/// # std::io::Result::Ok(())
/// ```
fn fill_buf_wc ( & mut self ) -> crate :: rewrite_output_type ! ( std :: io :: Result < & [ u8 ] > ) {
    < Self as :: std :: io :: BufRead > :: fill_buf(self)
        .with_context(|| crate::call_failed!(Some(crate::CustomDebugMessage("value of type impl std::io::BufRead")), "fill_buf"))
}
/// Skips all bytes until the delimiter `byte` or EOF is reached.
/// 
/// This function will read (and discard) bytes from the underlying stream until the
/// delimiter or EOF is found.
/// 
/// If successful, this function will return the total number of bytes read,
/// including the delimiter byte if found.
/// 
/// This is useful for efficiently skipping data such as NUL-terminated strings
/// in binary file formats without buffering.
/// 
/// This function is blocking and should be used carefully: it is possible for
/// an attacker to continuously send bytes without ever sending the delimiter
/// or EOF.
/// 
/// # Errors
/// 
/// This function will ignore all instances of [`ErrorKind::Interrupted`] and
/// will otherwise return any errors returned by [`fill_buf`].
/// 
/// If an I/O error is encountered then all bytes read so far will be
/// present in `buf` and its length will have been adjusted appropriately.
/// 
/// [`fill_buf`]: BufRead::fill_buf
/// 
/// # Examples
/// 
/// [`std::io::Cursor`][`Cursor`] is a type that implements `BufRead`. In
/// this example, we use [`Cursor`] to read some NUL-terminated information
/// about Ferris from a binary string, skipping the fun fact:
/// 
/// ```
/// use std::io::{self, BufRead};
/// 
/// let mut cursor = io::Cursor::new(b"Ferris\0Likes long walks on the beach\0Crustacean\0!");
/// 
/// // read name
/// let mut name = Vec::new();
/// let num_bytes = cursor.read_until(b'\0', &mut name)
///     .expect("reading from cursor won't fail");
/// assert_eq!(num_bytes, 7);
/// assert_eq!(name, b"Ferris\0");
/// 
/// // skip fun fact
/// let num_bytes = cursor.skip_until(b'\0')
///     .expect("reading from cursor won't fail");
/// assert_eq!(num_bytes, 30);
/// 
/// // read animal type
/// let mut animal = Vec::new();
/// let num_bytes = cursor.read_until(b'\0', &mut animal)
///     .expect("reading from cursor won't fail");
/// assert_eq!(num_bytes, 11);
/// assert_eq!(animal, b"Crustacean\0");
/// 
/// // reach EOF
/// let num_bytes = cursor.skip_until(b'\0')
///     .expect("reading from cursor won't fail");
/// assert_eq!(num_bytes, 1);
/// ```
#[cfg(feature = "bufread_skip_until")]
fn skip_until_wc ( & mut self , byte : u8 ) -> crate :: rewrite_output_type ! ( std :: io :: Result < usize > ) {
    < Self as :: std :: io :: BufRead > :: skip_until(self, byte)
        .with_context(|| crate::call_failed!(Some(self), "skip_until", byte))
}
}

impl<T> BufReadContext for T where T: std :: io :: BufRead {}
pub trait ReadContext: std :: io :: Read {
///  Reads all bytes until EOF in this source, appending them to `buf`.
/// 
///  If successful, this function returns the number of bytes which were read
///  and appended to `buf`.
/// 
///  # Errors
/// 
///  If the data in this stream is *not* valid UTF-8 then an error is
///  returned and `buf` is unchanged.
/// 
///  See [`read_to_end`] for other error semantics.
/// 
///  [`read_to_end`]: Read::read_to_end
/// 
///  # Examples
/// 
///  [`File`]s implement `Read`:
/// 
///  [`File`]: crate::fs::File
/// 
///  ```no_run
///  use std::io;
///  use std::io::prelude::*;
///  use std::fs::File;
/// 
///  fn main() -> io::Result<()> {
///      let mut f = File::open("foo.txt")?;
///      let mut buffer = String::new();
/// 
///      f.read_to_string(&mut buffer)?;
///      Ok(())
///  }
///  ```
/// 
///  (See also the [`std::fs::read_to_string`] convenience function for
///  reading from a file.)
/// 
///  # Usage Notes
/// 
///  `read_to_string` attempts to read a source until EOF, but many sources are continuous streams
///  that do not send EOF. In these cases, `read_to_string` will block indefinitely. Standard input
///  is one such stream which may be finite if piped, but is typically continuous. For example,
///  `cat file | my-rust-program` will correctly terminate with an `EOF` upon closure of cat.
///  Reading user input or running programs that remain open indefinitely will never terminate
///  the stream with `EOF` (e.g. `yes | my-rust-program`).
/// 
///  Using `.lines()` with a [`BufReader`] or using [`read`] can provide a better solution
/// 
/// [`read`]: Read::read
/// 
///  [`std::fs::read_to_string`]: crate::fs::read_to_string
fn read_to_string_wc ( & mut self , buf : & mut std :: string :: String ) -> crate :: rewrite_output_type ! ( std :: io :: Result < usize > ) {
    < Self as :: std :: io :: Read > :: read_to_string(self, buf)
        .with_context(|| crate::call_failed!(Some(self), "read_to_string", buf))
}
///  Reads all bytes until EOF in this source, placing them into `buf`.
/// 
///  All bytes read from this source will be appended to the specified buffer
///  `buf`. This function will continuously call [`read()`] to append more data to
///  `buf` until [`read()`] returns either [`Ok(0)`] or an error of
///  non-[`ErrorKind::Interrupted`] kind.
/// 
///  If successful, this function will return the total number of bytes read.
/// 
///  # Errors
/// 
///  If this function encounters an error of the kind
///  [`ErrorKind::Interrupted`] then the error is ignored and the operation
///  will continue.
/// 
///  If any other read error is encountered then this function immediately
///  returns. Any bytes which have already been read will be appended to
///  `buf`.
/// 
///  # Examples
/// 
///  [`File`]s implement `Read`:
/// 
///  [`read()`]: Read::read
///  [`Ok(0)`]: Ok
///  [`File`]: crate::fs::File
/// 
///  ```no_run
///  use std::io;
///  use std::io::prelude::*;
///  use std::fs::File;
/// 
///  fn main() -> io::Result<()> {
///      let mut f = File::open("foo.txt")?;
///      let mut buffer = Vec::new();
/// 
///      // read the whole file
///      f.read_to_end(&mut buffer)?;
///      Ok(())
///  }
///  ```
/// 
///  (See also the [`std::fs::read`] convenience function for reading from a
///  file.)
/// 
///  [`std::fs::read`]: crate::fs::read
/// 
///  ## Implementing `read_to_end`
/// 
///  When implementing the `io::Read` trait, it is recommended to allocate
///  memory using [`Vec::try_reserve`]. However, this behavior is not guaranteed
///  by all implementations, and `read_to_end` may not handle out-of-memory
///  situations gracefully.
/// 
///  ```no_run
///  # use std::io::{self, BufRead};
///  # struct Example { example_datasource: io::Empty } impl Example {
///  # fn get_some_data_for_the_example(&self) -> &'static [u8] { &[] }
///  fn read_to_end(&mut self, dest_vec: &mut Vec<u8>) -> io::Result<usize> {
///      let initial_vec_len = dest_vec.len();
///      loop {
///          let src_buf = self.example_datasource.fill_buf()?;
///          if src_buf.is_empty() {
///              break;
///          }
///          dest_vec.try_reserve(src_buf.len())?;
///          dest_vec.extend_from_slice(src_buf);
/// 
///          // Any irreversible side effects should happen after `try_reserve` succeeds,
///          // to avoid losing data on allocation error.
///          let read = src_buf.len();
///          self.example_datasource.consume(read);
///      }
///      Ok(dest_vec.len() - initial_vec_len)
///  }
///  # }
///  ```
/// 
///  # Usage Notes
/// 
///  `read_to_end` attempts to read a source until EOF, but many sources are continuous streams
///  that do not send EOF. In these cases, `read_to_end` will block indefinitely. Standard input
///  is one such stream which may be finite if piped, but is typically continuous. For example,
///  `cat file | my-rust-program` will correctly terminate with an `EOF` upon closure of cat.
///  Reading user input or running programs that remain open indefinitely will never terminate
///  the stream with `EOF` (e.g. `yes | my-rust-program`).
/// 
///  Using `.lines()` with a [`BufReader`] or using [`read`] can provide a better solution
/// 
/// [`read`]: Read::read
/// 
///  [`Vec::try_reserve`]: crate::vec::Vec::try_reserve
fn read_to_end_wc ( & mut self , buf : & mut std :: vec :: Vec < u8 > ) -> crate :: rewrite_output_type ! ( std :: io :: Result < usize > ) {
    < Self as :: std :: io :: Read > :: read_to_end(self, buf)
        .with_context(|| crate::call_failed!(Some(self), "read_to_end", buf))
}
/// Like `read`, except that it reads into a slice of buffers.
/// 
/// Data is copied to fill each buffer in order, with the final buffer
/// written to possibly being only partially filled. This method must
/// behave equivalently to a single call to `read` with concatenated
/// buffers.
/// 
/// The default implementation calls `read` with either the first nonempty
/// buffer provided, or an empty one if none exists.
fn read_vectored_wc ( & mut self , bufs : & mut [ std :: io :: IoSliceMut < '_ > ] ) -> crate :: rewrite_output_type ! ( std :: io :: Result < usize > ) {
    < Self as :: std :: io :: Read > :: read_vectored(self, bufs)
        .with_context(|| crate::call_failed!(Some(self), "read_vectored", bufs))
}
/// Pull some bytes from this source into the specified buffer, returning
/// how many bytes were read.
/// 
/// This function does not provide any guarantees about whether it blocks
/// waiting for data, but if an object needs to block for a read and cannot,
/// it will typically signal this via an [`Err`] return value.
/// 
/// If the return value of this method is [`Ok(n)`], then implementations must
/// guarantee that `0 <= n <= buf.len()`. A nonzero `n` value indicates
/// that the buffer `buf` has been filled in with `n` bytes of data from this
/// source. If `n` is `0`, then it can indicate one of two scenarios:
/// 
/// 1. This reader has reached its "end of file" and will likely no longer
///    be able to produce bytes. Note that this does not mean that the
///    reader will *always* no longer be able to produce bytes. As an example,
///    on Linux, this method will call the `recv` syscall for a [`TcpStream`],
///    where returning zero indicates the connection was shut down correctly. While
///    for [`File`], it is possible to reach the end of file and get zero as result,
///    but if more data is appended to the file, future calls to `read` will return
///    more data.
/// 2. The buffer specified was 0 bytes in length.
/// 
/// It is not an error if the returned value `n` is smaller than the buffer size,
/// even when the reader is not at the end of the stream yet.
/// This may happen for example because fewer bytes are actually available right now
/// (e. g. being close to end-of-file) or because read() was interrupted by a signal.
/// 
/// As this trait is safe to implement, callers in unsafe code cannot rely on
/// `n <= buf.len()` for safety.
/// Extra care needs to be taken when `unsafe` functions are used to access the read bytes.
/// Callers have to ensure that no unchecked out-of-bounds accesses are possible even if
/// `n > buf.len()`.
/// 
/// *Implementations* of this method can make no assumptions about the contents of `buf` when
/// this function is called. It is recommended that implementations only write data to `buf`
/// instead of reading its contents.
/// 
/// Correspondingly, however, *callers* of this method in unsafe code must not assume
/// any guarantees about how the implementation uses `buf`. The trait is safe to implement,
/// so it is possible that the code that's supposed to write to the buffer might also read
/// from it. It is your responsibility to make sure that `buf` is initialized
/// before calling `read`. Calling `read` with an uninitialized `buf` (of the kind one
/// obtains via [`MaybeUninit<T>`]) is not safe, and can lead to undefined behavior.
/// 
/// [`MaybeUninit<T>`]: crate::mem::MaybeUninit
/// 
/// # Errors
/// 
/// If this function encounters any form of I/O or other error, an error
/// variant will be returned. If an error is returned then it must be
/// guaranteed that no bytes were read.
/// 
/// An error of the [`ErrorKind::Interrupted`] kind is non-fatal and the read
/// operation should be retried if there is nothing else to do.
/// 
/// # Examples
/// 
/// [`File`]s implement `Read`:
/// 
/// [`Ok(n)`]: Ok
/// [`File`]: crate::fs::File
/// [`TcpStream`]: crate::net::TcpStream
/// 
/// ```no_run
/// use std::io;
/// use std::io::prelude::*;
/// use std::fs::File;
/// 
/// fn main() -> io::Result<()> {
///     let mut f = File::open("foo.txt")?;
///     let mut buffer = [0; 10];
/// 
///     // read up to 10 bytes
///     let n = f.read(&mut buffer[..])?;
/// 
///     println!("The bytes: {:?}", &buffer[..n]);
///     Ok(())
/// }
/// ```
fn read_wc ( & mut self , buf : & mut [ u8 ] ) -> crate :: rewrite_output_type ! ( std :: io :: Result < usize > ) {
    < Self as :: std :: io :: Read > :: read(self, buf)
        .with_context(|| crate::call_failed!(Some(self), "read", buf))
}
/// Pull some bytes from this source into the specified buffer.
/// 
/// This is equivalent to the [`read`](Read::read) method, except that it is passed a [`BorrowedCursor`] rather than `[u8]` to allow use
/// with uninitialized buffers. The new data will be appended to any existing contents of `buf`.
/// 
/// The default implementation delegates to `read`.
/// 
/// This method makes it possible to return both data and an error but it is advised against.
#[cfg(feature = "read_buf")]
fn read_buf_wc ( & mut self , buf : core :: io :: BorrowedCursor < '_ > ) -> crate :: rewrite_output_type ! ( std :: io :: Result < ( ) > ) {
    < Self as :: std :: io :: Read > :: read_buf(self, buf)
        .with_context(|| crate::call_failed!(Some(self), "read_buf", crate::CustomDebugMessage("value of type BorrowedCursor")))
}
/// Read and return a fixed array of bytes from this source.
/// 
/// This function uses an array sized based on a const generic size known at compile time. You
/// can specify the size with turbofish (`reader.read_array::<8>()`), or let type inference
/// determine the number of bytes needed based on how the return value gets used. For instance,
/// this function works well with functions like [`u64::from_le_bytes`] to turn an array of
/// bytes into an integer of the same size.
/// 
/// Like `read_exact`, if this function encounters an "end of file" before reading the desired
/// number of bytes, it returns an error of the kind [`ErrorKind::UnexpectedEof`].
/// 
/// ```
/// #![feature(read_array)]
/// use std::io::Cursor;
/// use std::io::prelude::*;
/// 
/// fn main() -> std::io::Result<()> {
///     let mut buf = Cursor::new([1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2]);
///     let x = u64::from_le_bytes(buf.read_array()?);
///     let y = u32::from_be_bytes(buf.read_array()?);
///     let z = u16::from_be_bytes(buf.read_array()?);
///     assert_eq!(x, 0x807060504030201);
///     assert_eq!(y, 0x9080706);
///     assert_eq!(z, 0x504);
///     Ok(())
/// }
/// ```
#[cfg(feature = "read_array")]
fn read_array_wc < const N : usize > ( & mut self ) -> crate :: rewrite_output_type ! ( std :: io :: Result < [ u8 ; N ] > ) where Self : core :: marker :: Sized {
    < Self as :: std :: io :: Read > :: read_array(self)
        .with_context(|| crate::call_failed!(Some(self), "read_array"))
}
/// Reads the exact number of bytes required to fill `buf`.
/// 
/// This function reads as many bytes as necessary to completely fill the
/// specified buffer `buf`.
/// 
/// *Implementations* of this method can make no assumptions about the contents of `buf` when
/// this function is called. It is recommended that implementations only write data to `buf`
/// instead of reading its contents. The documentation on [`read`] has a more detailed
/// explanation of this subject.
/// 
/// # Errors
/// 
/// If this function encounters an error of the kind
/// [`ErrorKind::Interrupted`] then the error is ignored and the operation
/// will continue.
/// 
/// If this function encounters an "end of file" before completely filling
/// the buffer, it returns an error of the kind [`ErrorKind::UnexpectedEof`].
/// The contents of `buf` are unspecified in this case.
/// 
/// If any other read error is encountered then this function immediately
/// returns. The contents of `buf` are unspecified in this case.
/// 
/// If this function returns an error, it is unspecified how many bytes it
/// has read, but it will never read more than would be necessary to
/// completely fill the buffer.
/// 
/// # Examples
/// 
/// [`File`]s implement `Read`:
/// 
/// [`read`]: Read::read
/// [`File`]: crate::fs::File
/// 
/// ```no_run
/// use std::io;
/// use std::io::prelude::*;
/// use std::fs::File;
/// 
/// fn main() -> io::Result<()> {
///     let mut f = File::open("foo.txt")?;
///     let mut buffer = [0; 10];
/// 
///     // read exactly 10 bytes
///     f.read_exact(&mut buffer)?;
///     Ok(())
/// }
/// ```
fn read_exact_wc ( & mut self , buf : & mut [ u8 ] ) -> crate :: rewrite_output_type ! ( std :: io :: Result < ( ) > ) {
    < Self as :: std :: io :: Read > :: read_exact(self, buf)
        .with_context(|| crate::call_failed!(Some(self), "read_exact", buf))
}
/// Reads the exact number of bytes required to fill `cursor`.
/// 
/// This is similar to the [`read_exact`](Read::read_exact) method, except
/// that it is passed a [`BorrowedCursor`] rather than `[u8]` to allow use
/// with uninitialized buffers.
/// 
/// # Errors
/// 
/// If this function encounters an error of the kind [`ErrorKind::Interrupted`]
/// then the error is ignored and the operation will continue.
/// 
/// If this function encounters an "end of file" before completely filling
/// the buffer, it returns an error of the kind [`ErrorKind::UnexpectedEof`].
/// 
/// If any other read error is encountered then this function immediately
/// returns.
/// 
/// If this function returns an error, all bytes read will be appended to `cursor`.
#[cfg(feature = "read_buf")]
fn read_buf_exact_wc ( & mut self , cursor : core :: io :: BorrowedCursor < '_ > ) -> crate :: rewrite_output_type ! ( std :: io :: Result < ( ) > ) {
    < Self as :: std :: io :: Read > :: read_buf_exact(self, cursor)
        .with_context(|| crate::call_failed!(Some(self), "read_buf_exact", crate::CustomDebugMessage("value of type BorrowedCursor")))
}
}

impl<T> ReadContext for T where T: std :: io :: Read {}
pub trait SeekContext: std :: io :: Seek {
/// Returns the current seek position from the start of the stream.
/// 
/// This is equivalent to `self.seek(SeekFrom::Current(0))`.
/// 
/// # Example
/// 
/// ```no_run
/// use std::{
///     io::{self, BufRead, BufReader, Seek},
///     fs::File,
/// };
/// 
/// fn main() -> io::Result<()> {
///     let mut f = BufReader::new(File::open("foo.txt")?);
/// 
///     let before = f.stream_position()?;
///     f.read_line(&mut String::new())?;
///     let after = f.stream_position()?;
/// 
///     println!("The first line was {} bytes long", after - before);
///     Ok(())
/// }
/// ```
fn stream_position_wc ( & mut self ) -> crate :: rewrite_output_type ! ( std :: io :: Result < u64 > ) {
    < Self as :: std :: io :: Seek > :: stream_position(self)
        .with_context(|| crate::call_failed!(Some(self), "stream_position"))
}
/// Returns the length of this stream (in bytes).
/// 
/// The default implementation uses up to three seek operations. If this
/// method returns successfully, the seek position is unchanged (i.e. the
/// position before calling this method is the same as afterwards).
/// However, if this method returns an error, the seek position is
/// unspecified.
/// 
/// If you need to obtain the length of *many* streams and you don't care
/// about the seek position afterwards, you can reduce the number of seek
/// operations by simply calling `seek(SeekFrom::End(0))` and using its
/// return value (it is also the stream length).
/// 
/// Note that length of a stream can change over time (for example, when
/// data is appended to a file). So calling this method multiple times does
/// not necessarily return the same length each time.
/// 
/// # Example
/// 
/// ```no_run
/// #![feature(seek_stream_len)]
/// use std::{
///     io::{self, Seek},
///     fs::File,
/// };
/// 
/// fn main() -> io::Result<()> {
///     let mut f = File::open("foo.txt")?;
/// 
///     let len = f.stream_len()?;
///     println!("The file is currently {len} bytes long");
///     Ok(())
/// }
/// ```
#[cfg(feature = "seek_stream_len")]
fn stream_len_wc ( & mut self ) -> crate :: rewrite_output_type ! ( std :: io :: Result < u64 > ) {
    < Self as :: std :: io :: Seek > :: stream_len(self)
        .with_context(|| crate::call_failed!(Some(self), "stream_len"))
}
/// Rewind to the beginning of a stream.
/// 
/// This is a convenience method, equivalent to `seek(SeekFrom::Start(0))`.
/// 
/// # Errors
/// 
/// Rewinding can fail, for example because it might involve flushing a buffer.
/// 
/// # Example
/// 
/// ```no_run
/// use std::io::{Read, Seek, Write};
/// use std::fs::OpenOptions;
/// 
/// let mut f = OpenOptions::new()
///     .write(true)
///     .read(true)
///     .create(true)
///     .open("foo.txt")?;
/// 
/// let hello = "Hello!\n";
/// write!(f, "{hello}")?;
/// f.rewind()?;
/// 
/// let mut buf = String::new();
/// f.read_to_string(&mut buf)?;
/// assert_eq!(&buf, hello);
/// # std::io::Result::Ok(())
/// ```
fn rewind_wc ( & mut self ) -> crate :: rewrite_output_type ! ( std :: io :: Result < ( ) > ) {
    < Self as :: std :: io :: Seek > :: rewind(self)
        .with_context(|| crate::call_failed!(Some(self), "rewind"))
}
/// Seek to an offset, in bytes, in a stream.
/// 
/// A seek beyond the end of a stream is allowed, but behavior is defined
/// by the implementation.
/// 
/// If the seek operation completed successfully,
/// this method returns the new position from the start of the stream.
/// That position can be used later with [`SeekFrom::Start`].
/// 
/// # Errors
/// 
/// Seeking can fail, for example because it might involve flushing a buffer.
/// 
/// Seeking to a negative offset is considered an error.
fn seek_wc ( & mut self , pos : std :: io :: SeekFrom ) -> crate :: rewrite_output_type ! ( std :: io :: Result < u64 > ) {
    < Self as :: std :: io :: Seek > :: seek(self, pos)
        .with_context(|| crate::call_failed!(Some(self), "seek", pos))
}
/// Seeks relative to the current position.
/// 
/// This is equivalent to `self.seek(SeekFrom::Current(offset))` but
/// doesn't return the new position which can allow some implementations
/// such as [`BufReader`] to perform more efficient seeks.
/// 
/// # Example
/// 
/// ```no_run
/// use std::{
///     io::{self, Seek},
///     fs::File,
/// };
/// 
/// fn main() -> io::Result<()> {
///     let mut f = File::open("foo.txt")?;
///     f.seek_relative(10)?;
///     assert_eq!(f.stream_position()?, 10);
///     Ok(())
/// }
/// ```
/// 
/// [`BufReader`]: crate::io::BufReader
fn seek_relative_wc ( & mut self , offset : i64 ) -> crate :: rewrite_output_type ! ( std :: io :: Result < ( ) > ) {
    < Self as :: std :: io :: Seek > :: seek_relative(self, offset)
        .with_context(|| crate::call_failed!(Some(self), "seek_relative", offset))
}
}

impl<T> SeekContext for T where T: std :: io :: Seek {}
pub trait WriteContext: std :: io :: Write {
/// Attempts to write an entire buffer into this writer.
/// 
/// This method will continuously call [`write`] until there is no more data
/// to be written or an error of non-[`ErrorKind::Interrupted`] kind is
/// returned. This method will not return until the entire buffer has been
/// successfully written or such an error occurs. The first error that is
/// not of [`ErrorKind::Interrupted`] kind generated from this method will be
/// returned.
/// 
/// If the buffer contains no data, this will never call [`write`].
/// 
/// # Errors
/// 
/// This function will return the first error of
/// non-[`ErrorKind::Interrupted`] kind that [`write`] returns.
/// 
/// [`write`]: Write::write
/// 
/// # Examples
/// 
/// ```no_run
/// use std::io::prelude::*;
/// use std::fs::File;
/// 
/// fn main() -> std::io::Result<()> {
///     let mut buffer = File::create("foo.txt")?;
/// 
///     buffer.write_all(b"some bytes")?;
///     Ok(())
/// }
/// ```
fn write_all_wc ( & mut self , buf : & [ u8 ] ) -> crate :: rewrite_output_type ! ( std :: io :: Result < ( ) > ) {
    < Self as :: std :: io :: Write > :: write_all(self, buf)
        .with_context(|| crate::call_failed!(Some(self), "write_all", buf))
}
/// Attempts to write multiple buffers into this writer.
/// 
/// This method will continuously call [`write_vectored`] until there is no
/// more data to be written or an error of non-[`ErrorKind::Interrupted`]
/// kind is returned. This method will not return until all buffers have
/// been successfully written or such an error occurs. The first error that
/// is not of [`ErrorKind::Interrupted`] kind generated from this method
/// will be returned.
/// 
/// If the buffer contains no data, this will never call [`write_vectored`].
/// 
/// # Notes
/// 
/// Unlike [`write_vectored`], this takes a *mutable* reference to
/// a slice of [`IoSlice`]s, not an immutable one. That's because we need to
/// modify the slice to keep track of the bytes already written.
/// 
/// Once this function returns, the contents of `bufs` are unspecified, as
/// this depends on how many calls to [`write_vectored`] were necessary. It is
/// best to understand this function as taking ownership of `bufs` and to
/// not use `bufs` afterwards. The underlying buffers, to which the
/// [`IoSlice`]s point (but not the [`IoSlice`]s themselves), are unchanged and
/// can be reused.
/// 
/// [`write_vectored`]: Write::write_vectored
/// 
/// # Examples
/// 
/// ```
/// #![feature(write_all_vectored)]
/// # fn main() -> std::io::Result<()> {
/// 
/// use std::io::{Write, IoSlice};
/// 
/// let mut writer = Vec::new();
/// let bufs = &mut [
///     IoSlice::new(&[1]),
///     IoSlice::new(&[2, 3]),
///     IoSlice::new(&[4, 5, 6]),
/// ];
/// 
/// writer.write_all_vectored(bufs)?;
/// // Note: the contents of `bufs` is now undefined, see the Notes section.
/// 
/// assert_eq!(writer, &[1, 2, 3, 4, 5, 6]);
/// # Ok(()) }
/// ```
#[cfg(feature = "write_all_vectored")]
fn write_all_vectored_wc ( & mut self , bufs : & mut [ std :: io :: IoSlice < '_ > ] ) -> crate :: rewrite_output_type ! ( std :: io :: Result < ( ) > ) {
    < Self as :: std :: io :: Write > :: write_all_vectored(self, bufs)
        .with_context(|| crate::call_failed!(Some(self), "write_all_vectored", bufs))
}
/// Flushes this output stream, ensuring that all intermediately buffered
/// contents reach their destination.
/// 
/// # Errors
/// 
/// It is considered an error if not all bytes could be written due to
/// I/O errors or EOF being reached.
/// 
/// # Examples
/// 
/// ```no_run
/// use std::io::prelude::*;
/// use std::io::BufWriter;
/// use std::fs::File;
/// 
/// fn main() -> std::io::Result<()> {
///     let mut buffer = BufWriter::new(File::create("foo.txt")?);
/// 
///     buffer.write_all(b"some bytes")?;
///     buffer.flush()?;
///     Ok(())
/// }
/// ```
fn flush_wc ( & mut self ) -> crate :: rewrite_output_type ! ( std :: io :: Result < ( ) > ) {
    < Self as :: std :: io :: Write > :: flush(self)
        .with_context(|| crate::call_failed!(Some(self), "flush"))
}
/// Like [`write`], except that it writes from a slice of buffers.
/// 
/// Data is copied from each buffer in order, with the final buffer
/// read from possibly being only partially consumed. This method must
/// behave as a call to [`write`] with the buffers concatenated would.
/// 
/// The default implementation calls [`write`] with either the first nonempty
/// buffer provided, or an empty one if none exists.
/// 
/// # Examples
/// 
/// ```no_run
/// use std::io::IoSlice;
/// use std::io::prelude::*;
/// use std::fs::File;
/// 
/// fn main() -> std::io::Result<()> {
///     let data1 = [1; 8];
///     let data2 = [15; 8];
///     let io_slice1 = IoSlice::new(&data1);
///     let io_slice2 = IoSlice::new(&data2);
/// 
///     let mut buffer = File::create("foo.txt")?;
/// 
///     // Writes some prefix of the byte string, not necessarily all of it.
///     buffer.write_vectored(&[io_slice1, io_slice2])?;
///     Ok(())
/// }
/// ```
/// 
/// [`write`]: Write::write
fn write_vectored_wc ( & mut self , bufs : & [ std :: io :: IoSlice < '_ > ] ) -> crate :: rewrite_output_type ! ( std :: io :: Result < usize > ) {
    < Self as :: std :: io :: Write > :: write_vectored(self, bufs)
        .with_context(|| crate::call_failed!(Some(self), "write_vectored", bufs))
}
/// Writes a buffer into this writer, returning how many bytes were written.
/// 
/// This function will attempt to write the entire contents of `buf`, but
/// the entire write might not succeed, or the write may also generate an
/// error. Typically, a call to `write` represents one attempt to write to
/// any wrapped object.
/// 
/// Calls to `write` are not guaranteed to block waiting for data to be
/// written, and a write which would otherwise block can be indicated through
/// an [`Err`] variant.
/// 
/// If this method consumed `n > 0` bytes of `buf` it must return [`Ok(n)`].
/// If the return value is `Ok(n)` then `n` must satisfy `n <= buf.len()`.
/// A return value of `Ok(0)` typically means that the underlying object is
/// no longer able to accept bytes and will likely not be able to in the
/// future as well, or that the buffer provided is empty.
/// 
/// # Errors
/// 
/// Each call to `write` may generate an I/O error indicating that the
/// operation could not be completed. If an error is returned then no bytes
/// in the buffer were written to this writer.
/// 
/// It is **not** considered an error if the entire buffer could not be
/// written to this writer.
/// 
/// An error of the [`ErrorKind::Interrupted`] kind is non-fatal and the
/// write operation should be retried if there is nothing else to do.
/// 
/// # Examples
/// 
/// ```no_run
/// use std::io::prelude::*;
/// use std::fs::File;
/// 
/// fn main() -> std::io::Result<()> {
///     let mut buffer = File::create("foo.txt")?;
/// 
///     // Writes some prefix of the byte string, not necessarily all of it.
///     buffer.write(b"some bytes")?;
///     Ok(())
/// }
/// ```
/// 
/// [`Ok(n)`]: Ok
fn write_wc ( & mut self , buf : & [ u8 ] ) -> crate :: rewrite_output_type ! ( std :: io :: Result < usize > ) {
    < Self as :: std :: io :: Write > :: write(self, buf)
        .with_context(|| crate::call_failed!(Some(self), "write", buf))
}
/// Writes a formatted string into this writer, returning any error
/// encountered.
/// 
/// This method is primarily used to interface with the
/// [`format_args!()`] macro, and it is rare that this should
/// explicitly be called. The [`write!()`] macro should be favored to
/// invoke this method instead.
/// 
/// This function internally uses the [`write_all`] method on
/// this trait and hence will continuously write data so long as no errors
/// are received. This also means that partial writes are not indicated in
/// this signature.
/// 
/// [`write_all`]: Write::write_all
/// 
/// # Errors
/// 
/// This function will return any I/O error reported while formatting.
/// 
/// # Examples
/// 
/// ```no_run
/// use std::io::prelude::*;
/// use std::fs::File;
/// 
/// fn main() -> std::io::Result<()> {
///     let mut buffer = File::create("foo.txt")?;
/// 
///     // this call
///     write!(buffer, "{:.*}", 2, 1.234567)?;
///     // turns into this:
///     buffer.write_fmt(format_args!("{:.*}", 2, 1.234567))?;
///     Ok(())
/// }
/// ```
fn write_fmt_wc ( & mut self , args : core :: fmt :: Arguments < '_ > ) -> crate :: rewrite_output_type ! ( std :: io :: Result < ( ) > ) {
    < Self as :: std :: io :: Write > :: write_fmt(self, args)
        .with_context(|| crate::call_failed!(Some(self), "write_fmt", args))
}
}

impl<T> WriteContext for T where T: std :: io :: Write {}

pub trait ErrorContext {
/// Consumes the `Error`, returning its inner error (if any).
/// 
/// If this [`Error`] was constructed via [`new`] or [`other`],
/// then this function will return [`Some`],
/// otherwise it will return [`None`].
/// 
/// [`new`]: Error::new
/// [`other`]: Error::other
/// 
/// # Examples
/// 
/// ```
/// use std::io::{Error, ErrorKind};
/// 
/// fn print_error(err: Error) {
///     if let Some(inner_err) = err.into_inner() {
///         println!("Inner error: {inner_err}");
///     } else {
///         println!("No inner error");
///     }
/// }
/// 
/// fn main() {
///     // Will print "No inner error".
///     print_error(Error::last_os_error());
///     // Will print "Inner error: ...".
///     print_error(Error::new(ErrorKind::Other, "oh no!"));
/// }
/// ```
fn into_inner_wc ( self ) -> crate :: rewrite_output_type ! ( core :: option :: Option < std :: boxed :: Box < ( dyn core :: error :: Error + core :: marker :: Send + core :: marker :: Sync ) > > );
/// Returns a mutable reference to the inner error wrapped by this error
/// (if any).
/// 
/// If this [`Error`] was constructed via [`new`] then this function will
/// return [`Some`], otherwise it will return [`None`].
/// 
/// [`new`]: Error::new
/// 
/// # Examples
/// 
/// ```
/// use std::io::{Error, ErrorKind};
/// use std::{error, fmt};
/// use std::fmt::Display;
/// 
/// #[derive(Debug)]
/// struct MyError {
///     v: String,
/// }
/// 
/// impl MyError {
///     fn new() -> MyError {
///         MyError {
///             v: "oh no!".to_string()
///         }
///     }
/// 
///     fn change_message(&mut self, new_message: &str) {
///         self.v = new_message.to_string();
///     }
/// }
/// 
/// impl error::Error for MyError {}
/// 
/// impl Display for MyError {
///     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
///         write!(f, "MyError: {}", self.v)
///     }
/// }
/// 
/// fn change_error(mut err: Error) -> Error {
///     if let Some(inner_err) = err.get_mut() {
///         inner_err.downcast_mut::<MyError>().unwrap().change_message("I've been changed!");
///     }
///     err
/// }
/// 
/// fn print_error(err: &Error) {
///     if let Some(inner_err) = err.get_ref() {
///         println!("Inner error: {inner_err}");
///     } else {
///         println!("No inner error");
///     }
/// }
/// 
/// fn main() {
///     // Will print "No inner error".
///     print_error(&change_error(Error::last_os_error()));
///     // Will print "Inner error: ...".
///     print_error(&change_error(Error::new(ErrorKind::Other, MyError::new())));
/// }
/// ```
fn get_mut_wc ( & mut self ) -> crate :: rewrite_output_type ! ( core :: option :: Option < & mut ( dyn core :: error :: Error + core :: marker :: Send + core :: marker :: Sync + 'static ) > );
/// Returns a reference to the inner error wrapped by this error (if any).
/// 
/// If this [`Error`] was constructed via [`new`] then this function will
/// return [`Some`], otherwise it will return [`None`].
/// 
/// [`new`]: Error::new
/// 
/// # Examples
/// 
/// ```
/// use std::io::{Error, ErrorKind};
/// 
/// fn print_error(err: &Error) {
///     if let Some(inner_err) = err.get_ref() {
///         println!("Inner error: {inner_err:?}");
///     } else {
///         println!("No inner error");
///     }
/// }
/// 
/// fn main() {
///     // Will print "No inner error".
///     print_error(&Error::last_os_error());
///     // Will print "Inner error: ...".
///     print_error(&Error::new(ErrorKind::Other, "oh no!"));
/// }
/// ```
fn get_ref_wc ( & self ) -> crate :: rewrite_output_type ! ( core :: option :: Option < & ( dyn core :: error :: Error + core :: marker :: Send + core :: marker :: Sync + 'static ) > );
/// Returns the OS error that this error represents (if any).
/// 
/// If this [`Error`] was constructed via [`last_os_error`] or
/// [`from_raw_os_error`], then this function will return [`Some`], otherwise
/// it will return [`None`].
/// 
/// [`last_os_error`]: Error::last_os_error
/// [`from_raw_os_error`]: Error::from_raw_os_error
/// 
/// # Examples
/// 
/// ```
/// use std::io::{Error, ErrorKind};
/// 
/// fn print_os_error(err: &Error) {
///     if let Some(raw_os_err) = err.raw_os_error() {
///         println!("raw OS error: {raw_os_err:?}");
///     } else {
///         println!("Not an OS error");
///     }
/// }
/// 
/// fn main() {
///     // Will print "raw OS error: ...".
///     print_os_error(&Error::last_os_error());
///     // Will print "Not an OS error".
///     print_os_error(&Error::new(ErrorKind::Other, "oh no!"));
/// }
/// ```
#[cfg(feature = "raw_os_error_ty")]
fn raw_os_error_wc ( & self ) -> crate :: rewrite_output_type ! ( core :: option :: Option < std :: io :: RawOsError > );
}
impl ErrorContext for std :: io :: Error {
fn into_inner_wc ( self ) -> crate :: rewrite_output_type ! ( core :: option :: Option < std :: boxed :: Box < ( dyn core :: error :: Error + core :: marker :: Send + core :: marker :: Sync ) > > ) {
    std :: io :: Error :: into_inner(self)
        .with_context(|| crate::call_failed!(Some(crate::CustomDebugMessage("value of type std::io::Error")), "into_inner"))
}
fn get_mut_wc ( & mut self ) -> crate :: rewrite_output_type ! ( core :: option :: Option < & mut ( dyn core :: error :: Error + core :: marker :: Send + core :: marker :: Sync + 'static ) > ) {
    std :: io :: Error :: get_mut(self)
        .with_context(|| crate::call_failed!(Some(crate::CustomDebugMessage("value of type std::io::Error")), "get_mut"))
}
fn get_ref_wc ( & self ) -> crate :: rewrite_output_type ! ( core :: option :: Option < & ( dyn core :: error :: Error + core :: marker :: Send + core :: marker :: Sync + 'static ) > ) {
    std :: io :: Error :: get_ref(self)
        .with_context(|| crate::call_failed!(Some(self), "get_ref"))
}
#[cfg(feature = "raw_os_error_ty")]
fn raw_os_error_wc ( & self ) -> crate :: rewrite_output_type ! ( core :: option :: Option < std :: io :: RawOsError > ) {
    std :: io :: Error :: raw_os_error(self)
        .with_context(|| crate::call_failed!(Some(self), "raw_os_error"))
}
}
pub trait PipeReaderContext: Sized {
/// Creates a new [`PipeReader`] instance that shares the same underlying file description.
/// 
/// # Examples
/// 
/// ```no_run
/// # #[cfg(miri)] fn main() {}
/// # #[cfg(not(miri))]
/// # fn main() -> std::io::Result<()> {
/// use std::fs;
/// use std::io::{pipe, Write};
/// use std::process::Command;
/// const NUM_SLOT: u8 = 2;
/// const NUM_PROC: u8 = 5;
/// const OUTPUT: &str = "work.txt";
/// 
/// let mut jobs = vec![];
/// let (reader, mut writer) = pipe()?;
/// 
/// // Write NUM_SLOT characters the pipe.
/// writer.write_all(&[b'|'; NUM_SLOT as usize])?;
/// 
/// // Spawn several processes that read a character from the pipe, do some work, then
/// // write back to the pipe. When the pipe is empty, the processes block, so only
/// // NUM_SLOT processes can be working at any given time.
/// for _ in 0..NUM_PROC {
///     jobs.push(
///         Command::new("bash")
///             .args(["-c",
///                 &format!(
///                      "read -n 1\n\
///                       echo -n 'x' >> '{OUTPUT}'\n\
///                       echo -n '|'",
///                 ),
///             ])
///             .stdin(reader.try_clone()?)
///             .stdout(writer.try_clone()?)
///             .spawn()?,
///     );
/// }
/// 
/// // Wait for all jobs to finish.
/// for mut job in jobs {
///     job.wait()?;
/// }
/// 
/// // Check our work and clean up.
/// let xs = fs::read_to_string(OUTPUT)?;
/// fs::remove_file(OUTPUT)?;
/// assert_eq!(xs, "x".repeat(NUM_PROC.into()));
/// # Ok(())
/// # }
/// ```
fn try_clone_wc ( & self ) -> crate :: rewrite_output_type ! ( std :: io :: Result < Self > );
}
impl PipeReaderContext for std :: io :: PipeReader {
fn try_clone_wc ( & self ) -> crate :: rewrite_output_type ! ( std :: io :: Result < Self > ) {
    std :: io :: PipeReader :: try_clone(self)
        .with_context(|| crate::call_failed!(Some(self), "try_clone"))
}
}
pub trait PipeWriterContext: Sized {
/// Creates a new [`PipeWriter`] instance that shares the same underlying file description.
/// 
/// # Examples
/// 
/// ```no_run
/// # #[cfg(miri)] fn main() {}
/// # #[cfg(not(miri))]
/// # fn main() -> std::io::Result<()> {
/// use std::process::Command;
/// use std::io::{pipe, Read};
/// let (mut reader, writer) = pipe()?;
/// 
/// // Spawn a process that writes to stdout and stderr.
/// let mut peer = Command::new("bash")
///     .args([
///         "-c",
///         "echo -n foo\n\
///          echo -n bar >&2"
///     ])
///     .stdout(writer.try_clone()?)
///     .stderr(writer)
///     .spawn()?;
/// 
/// // Read and check the result.
/// let mut msg = String::new();
/// reader.read_to_string(&mut msg)?;
/// assert_eq!(&msg, "foobar");
/// 
/// peer.wait()?;
/// # Ok(())
/// # }
/// ```
fn try_clone_wc ( & self ) -> crate :: rewrite_output_type ! ( std :: io :: Result < Self > );
}
impl PipeWriterContext for std :: io :: PipeWriter {
fn try_clone_wc ( & self ) -> crate :: rewrite_output_type ! ( std :: io :: Result < Self > ) {
    std :: io :: PipeWriter :: try_clone(self)
        .with_context(|| crate::call_failed!(Some(self), "try_clone"))
}
}
pub trait StdinContext {
/// Locks this handle and reads a line of input, appending it to the specified buffer.
/// 
/// For detailed semantics of this method, see the documentation on
/// [`BufRead::read_line`]. In particular:
/// * Previous content of the buffer will be preserved. To avoid appending
///   to the buffer, you need to [`clear`] it first.
/// * The trailing newline character, if any, is included in the buffer.
/// 
/// [`clear`]: String::clear
/// 
/// # Examples
/// 
/// ```no_run
/// use std::io;
/// 
/// let mut input = String::new();
/// match io::stdin().read_line(&mut input) {
///     Ok(n) => {
///         println!("{n} bytes read");
///         println!("{input}");
///     }
///     Err(error) => println!("error: {error}"),
/// }
/// ```
/// 
/// You can run the example one of two ways:
/// 
/// - Pipe some text to it, e.g., `printf foo | path/to/executable`
/// - Give it text interactively by running the executable directly,
///   in which case it will wait for the Enter key to be pressed before
///   continuing
fn read_line_wc ( & self , buf : & mut std :: string :: String ) -> crate :: rewrite_output_type ! ( std :: io :: Result < usize > );
}
impl StdinContext for std :: io :: Stdin {
fn read_line_wc ( & self , buf : & mut std :: string :: String ) -> crate :: rewrite_output_type ! ( std :: io :: Result < usize > ) {
    std :: io :: Stdin :: read_line(self, buf)
        .with_context(|| crate::call_failed!(Some(self), "read_line", buf))
}
}


///  Reads all bytes from a [reader][Read] into a new [`String`].
/// 
///  This is a convenience function for [`Read::read_to_string`]. Using this
///  function avoids having to create a variable first and provides more type
///  safety since you can only get the buffer out if there were no errors. (If you
///  use [`Read::read_to_string`] you have to remember to check whether the read
///  succeeded because otherwise your buffer will be empty or only partially full.)
/// 
///  # Performance
/// 
///  The downside of this function's increased ease of use and type safety is
///  that it gives you less control over performance. For example, you can't
///  pre-allocate memory like you can using [`String::with_capacity`] and
///  [`Read::read_to_string`]. Also, you can't re-use the buffer if an error
///  occurs while reading.
/// 
///  In many cases, this function's performance will be adequate and the ease of use
///  and type safety tradeoffs will be worth it. However, there are cases where you
///  need more control over performance, and in those cases you should definitely use
///  [`Read::read_to_string`] directly.
/// 
///  Note that in some special cases, such as when reading files, this function will
///  pre-allocate memory based on the size of the input it is reading. In those
///  cases, the performance should be as good as if you had used
///  [`Read::read_to_string`] with a manually pre-allocated buffer.
/// 
///  # Errors
/// 
///  This function forces you to handle errors because the output (the `String`)
///  is wrapped in a [`Result`]. See [`Read::read_to_string`] for the errors
///  that can occur. If any error occurs, you will get an [`Err`], so you
///  don't have to worry about your buffer being empty or partially full.
/// 
///  # Examples
/// 
///  ```no_run
///  # use std::io;
///  fn main() -> io::Result<()> {
///      let stdin = io::read_to_string(io::stdin())?;
///      println!("Stdin was:");
///      println!("{stdin}");
///      Ok(())
///  }
///  ```
/// 
///  # Usage Notes
/// 
///  `read_to_string` attempts to read a source until EOF, but many sources are continuous streams
///  that do not send EOF. In these cases, `read_to_string` will block indefinitely. Standard input
///  is one such stream which may be finite if piped, but is typically continuous. For example,
///  `cat file | my-rust-program` will correctly terminate with an `EOF` upon closure of cat.
///  Reading user input or running programs that remain open indefinitely will never terminate
///  the stream with `EOF` (e.g. `yes | my-rust-program`).
/// 
///  Using `.lines()` with a [`BufReader`] or using [`read`] can provide a better solution
/// 
/// [`read`]: Read::read
pub fn read_to_string_wc < R : std :: io :: Read > ( reader : R ) -> crate :: rewrite_output_type ! ( std :: io :: Result < std :: string :: String > ) {
    std :: io :: read_to_string(reader)
        .with_context(|| crate::call_failed!(None::<()>, "std::io::read_to_string", crate::CustomDebugMessage("value of type impl Read")))
}
/// Copies the entire contents of a reader into a writer.
/// 
/// This function will continuously read data from `reader` and then
/// write it into `writer` in a streaming fashion until `reader`
/// returns EOF.
/// 
/// On success, the total number of bytes that were copied from
/// `reader` to `writer` is returned.
/// 
/// If you want to copy the contents of one file to another and you’re
/// working with filesystem paths, see the [`fs::copy`] function.
/// 
/// [`fs::copy`]: crate::fs::copy
/// 
/// # Errors
/// 
/// This function will return an error immediately if any call to [`read`] or
/// [`write`] returns an error. All instances of [`ErrorKind::Interrupted`] are
/// handled by this function and the underlying operation is retried.
/// 
/// [`read`]: Read::read
/// [`write`]: Write::write
/// [`ErrorKind::Interrupted`]: crate::io::ErrorKind::Interrupted
/// 
/// # Examples
/// 
/// ```
/// use std::io;
/// 
/// fn main() -> io::Result<()> {
///     let mut reader: &[u8] = b"hello";
///     let mut writer: Vec<u8> = vec![];
/// 
///     io::copy(&mut reader, &mut writer)?;
/// 
///     assert_eq!(&b"hello"[..], &writer[..]);
///     Ok(())
/// }
/// ```
/// 
/// # Platform-specific behavior
/// 
/// On Linux (including Android), this function uses `copy_file_range(2)`,
/// `sendfile(2)` or `splice(2)` syscalls to move data directly between file
/// descriptors if possible.
/// 
/// Note that platform-specific behavior [may change in the future][changes].
/// 
/// [changes]: crate::io#platform-specific-behavior
pub fn copy_wc < R , W > ( reader : & mut R , writer : & mut W ) -> crate :: rewrite_output_type ! ( std :: io :: Result < u64 > ) where R : std :: io :: Read + ? core :: marker :: Sized , W : std :: io :: Write + ? core :: marker :: Sized {
    std :: io :: copy(reader, writer)
        .with_context(|| crate::call_failed!(None::<()>, "std::io::copy", reader, writer))
}
/// Creates an anonymous pipe.
/// 
/// # Behavior
/// 
/// A pipe is a one-way data channel provided by the OS, which works across processes. A pipe is
/// typically used to communicate between two or more separate processes, as there are better,
/// faster ways to communicate within a single process.
/// 
/// In particular:
/// 
/// * A read on a [`PipeReader`] blocks until the pipe is non-empty.
/// * A write on a [`PipeWriter`] blocks when the pipe is full.
/// * When all copies of a [`PipeWriter`] are closed, a read on the corresponding [`PipeReader`]
///   returns EOF.
/// * [`PipeWriter`] can be shared, and multiple processes or threads can write to it at once, but
///   writes (above a target-specific threshold) may have their data interleaved.
/// * [`PipeReader`] can be shared, and multiple processes or threads can read it at once. Any
///   given byte will only get consumed by one reader. There are no guarantees about data
///   interleaving.
/// * Portable applications cannot assume any atomicity of messages larger than a single byte.
/// 
/// # Platform-specific behavior
/// 
/// This function currently corresponds to the `pipe` function on Unix and the
/// `CreatePipe` function on Windows.
/// 
/// Note that this [may change in the future][changes].
/// 
/// # Capacity
/// 
/// Pipe capacity is platform dependent. To quote the Linux [man page]:
/// 
/// > Different implementations have different limits for the pipe capacity. Applications should
/// > not rely on a particular capacity: an application should be designed so that a reading process
/// > consumes data as soon as it is available, so that a writing process does not remain blocked.
/// 
/// # Example
/// 
/// ```no_run
/// # #[cfg(miri)] fn main() {}
/// # #[cfg(not(miri))]
/// # fn main() -> std::io::Result<()> {
/// use std::io::{Read, Write, pipe};
/// use std::process::Command;
/// let (ping_reader, mut ping_writer) = pipe()?;
/// let (mut pong_reader, pong_writer) = pipe()?;
/// 
/// // Spawn a child process that echoes its input.
/// let mut echo_command = Command::new("cat");
/// echo_command.stdin(ping_reader);
/// echo_command.stdout(pong_writer);
/// let mut echo_child = echo_command.spawn()?;
/// 
/// // Send input to the child process. Note that because we're writing all the input before we
/// // read any output, this could deadlock if the child's input and output pipe buffers both
/// // filled up. Those buffers are usually at least a few KB, so "hello" is fine, but for longer
/// // inputs we'd need to read and write at the same time, e.g. using threads.
/// ping_writer.write_all(b"hello")?;
/// 
/// // `cat` exits when it reads EOF from stdin, but that can't happen while any ping writer
/// // remains open. We need to drop our ping writer, or read_to_string will deadlock below.
/// drop(ping_writer);
/// 
/// // The pong reader can't report EOF while any pong writer remains open. Our Command object is
/// // holding a pong writer, and again read_to_string will deadlock if we don't drop it.
/// drop(echo_command);
/// 
/// let mut buf = String::new();
/// // Block until `cat` closes its stdout (a pong writer).
/// pong_reader.read_to_string(&mut buf)?;
/// assert_eq!(&buf, "hello");
/// 
/// // At this point we know `cat` has exited, but we still need to wait to clean up the "zombie".
/// echo_child.wait()?;
/// # Ok(())
/// # }
/// ```
/// [changes]: io#platform-specific-behavior
/// [man page]: https://man7.org/linux/man-pages/man7/pipe.7.html
pub fn pipe_wc ( ) -> crate :: rewrite_output_type ! ( std :: io :: Result < ( std :: io :: PipeReader , std :: io :: PipeWriter ) > ) {
    std :: io :: pipe()
        .with_context(|| crate::call_failed!(None::<()>, "std::io::pipe"))
}