@@ -8,6 +8,7 @@ use crate::io::{
8
8
self , BufRead , ErrorKind , IoSlice , IoSliceMut , Read , ReadBuf , Seek , SeekFrom , Write ,
9
9
} ;
10
10
use crate :: mem;
11
+ use crate :: sync:: Arc ;
11
12
12
13
// =============================================================================
13
14
// Forwarding implementations
@@ -219,6 +220,96 @@ impl<B: BufRead + ?Sized> BufRead for Box<B> {
219
220
( * * self ) . read_line ( buf)
220
221
}
221
222
}
223
+ #[ stable( feature = "io_traits_arc" , since = "1.61.0" ) ]
224
+ impl < R : ?Sized > Read for Arc < R >
225
+ where
226
+ for < ' a > & ' a R : Read ,
227
+ {
228
+ #[ inline]
229
+ fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
230
+ ( & * * self ) . read ( buf)
231
+ }
232
+
233
+ #[ inline]
234
+ fn read_buf ( & mut self , buf : & mut ReadBuf < ' _ > ) -> io:: Result < ( ) > {
235
+ ( & * * self ) . read_buf ( buf)
236
+ }
237
+
238
+ #[ inline]
239
+ fn read_vectored ( & mut self , bufs : & mut [ IoSliceMut < ' _ > ] ) -> io:: Result < usize > {
240
+ ( & * * self ) . read_vectored ( bufs)
241
+ }
242
+
243
+ #[ inline]
244
+ fn is_read_vectored ( & self ) -> bool {
245
+ ( & * * self ) . is_read_vectored ( )
246
+ }
247
+
248
+ #[ inline]
249
+ fn read_to_end ( & mut self , buf : & mut Vec < u8 > ) -> io:: Result < usize > {
250
+ ( & * * self ) . read_to_end ( buf)
251
+ }
252
+
253
+ #[ inline]
254
+ fn read_to_string ( & mut self , buf : & mut String ) -> io:: Result < usize > {
255
+ ( & * * self ) . read_to_string ( buf)
256
+ }
257
+
258
+ #[ inline]
259
+ fn read_exact ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < ( ) > {
260
+ ( & * * self ) . read_exact ( buf)
261
+ }
262
+ }
263
+ #[ stable( feature = "io_traits_arc" , since = "1.61.0" ) ]
264
+ impl < W : ?Sized > Write for Arc < W >
265
+ where
266
+ for < ' a > & ' a W : Write ,
267
+ {
268
+ #[ inline]
269
+ fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
270
+ ( & * * self ) . write ( buf)
271
+ }
272
+
273
+ #[ inline]
274
+ fn write_vectored ( & mut self , bufs : & [ IoSlice < ' _ > ] ) -> io:: Result < usize > {
275
+ ( & * * self ) . write_vectored ( bufs)
276
+ }
277
+
278
+ #[ inline]
279
+ fn is_write_vectored ( & self ) -> bool {
280
+ ( & * * self ) . is_write_vectored ( )
281
+ }
282
+
283
+ #[ inline]
284
+ fn flush ( & mut self ) -> io:: Result < ( ) > {
285
+ ( & * * self ) . flush ( )
286
+ }
287
+
288
+ #[ inline]
289
+ fn write_all ( & mut self , buf : & [ u8 ] ) -> io:: Result < ( ) > {
290
+ ( & * * self ) . write_all ( buf)
291
+ }
292
+
293
+ #[ inline]
294
+ fn write_fmt ( & mut self , fmt : fmt:: Arguments < ' _ > ) -> io:: Result < ( ) > {
295
+ ( & * * self ) . write_fmt ( fmt)
296
+ }
297
+ }
298
+ #[ stable( feature = "io_traits_arc" , since = "1.61.0" ) ]
299
+ impl < S : ?Sized > Seek for Arc < S >
300
+ where
301
+ for < ' a > & ' a S : Seek ,
302
+ {
303
+ #[ inline]
304
+ fn seek ( & mut self , pos : SeekFrom ) -> io:: Result < u64 > {
305
+ ( & * * self ) . seek ( pos)
306
+ }
307
+
308
+ #[ inline]
309
+ fn stream_position ( & mut self ) -> io:: Result < u64 > {
310
+ ( & * * self ) . stream_position ( )
311
+ }
312
+ }
222
313
223
314
// =============================================================================
224
315
// In-memory buffer implementations
0 commit comments