@@ -53,11 +53,11 @@ pub use self::chain::Chain;
53
53
mod close;
54
54
pub use self :: close:: Close ;
55
55
56
- mod copy_into ;
57
- pub use self :: copy_into :: CopyInto ;
56
+ mod copy ;
57
+ pub use self :: copy :: { copy , Copy } ;
58
58
59
- mod copy_buf_into ;
60
- pub use self :: copy_buf_into :: CopyBufInto ;
59
+ mod copy_buf ;
60
+ pub use self :: copy_buf :: { copy_buf , CopyBuf } ;
61
61
62
62
mod cursor;
63
63
pub use self :: cursor:: Cursor ;
@@ -157,39 +157,6 @@ pub trait AsyncReadExt: AsyncRead {
157
157
Chain :: new ( self , next)
158
158
}
159
159
160
- /// Creates a future which copies all the bytes from one object to another.
161
- ///
162
- /// The returned future will copy all the bytes read from this `AsyncRead` into the
163
- /// `writer` specified. This future will only complete once the `reader` has hit
164
- /// EOF and all bytes have been written to and flushed from the `writer`
165
- /// provided.
166
- ///
167
- /// On success the number of bytes is returned.
168
- ///
169
- /// # Examples
170
- ///
171
- /// ```
172
- /// # futures::executor::block_on(async {
173
- /// use futures::io::{AsyncReadExt, AsyncWriteExt, Cursor};
174
- ///
175
- /// let reader = Cursor::new([1, 2, 3, 4]);
176
- /// let mut writer = Cursor::new(vec![0u8; 5]);
177
- ///
178
- /// let bytes = reader.copy_into(&mut writer).await?;
179
- /// writer.close().await?;
180
- ///
181
- /// assert_eq!(bytes, 4);
182
- /// assert_eq!(writer.into_inner(), [1, 2, 3, 4, 0]);
183
- /// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
184
- /// ```
185
- fn copy_into < W > ( self , writer : & mut W ) -> CopyInto < ' _ , Self , W >
186
- where
187
- Self : Sized ,
188
- W : AsyncWrite + Unpin + ?Sized ,
189
- {
190
- CopyInto :: new ( self , writer)
191
- }
192
-
193
160
/// Tries to read some bytes directly into the given `buf` in asynchronous
194
161
/// manner, returning a future type.
195
162
///
@@ -342,7 +309,7 @@ pub trait AsyncReadExt: AsyncRead {
342
309
///
343
310
/// ```
344
311
/// # futures::executor::block_on(async {
345
- /// use futures::io::{AsyncReadExt, Cursor};
312
+ /// use futures::io::{self, AsyncReadExt, Cursor};
346
313
///
347
314
/// // Note that for `Cursor` the read and write halves share a single
348
315
/// // seek position. This may or may not be true for other types that
@@ -354,8 +321,8 @@ pub trait AsyncReadExt: AsyncRead {
354
321
///
355
322
/// {
356
323
/// let (buffer_reader, mut buffer_writer) = (&mut buffer).split();
357
- /// reader.copy_into( &mut buffer_writer).await?;
358
- /// buffer_reader.copy_into( &mut writer).await?;
324
+ /// io::copy(reader, &mut buffer_writer).await?;
325
+ /// io::copy(buffer_reader, &mut writer).await?;
359
326
/// }
360
327
///
361
328
/// assert_eq!(buffer.into_inner(), [1, 2, 3, 4, 5, 6, 7, 8]);
@@ -558,39 +525,6 @@ impl<S: AsyncSeek + ?Sized> AsyncSeekExt for S {}
558
525
559
526
/// An extension trait which adds utility methods to `AsyncBufRead` types.
560
527
pub trait AsyncBufReadExt : AsyncBufRead {
561
- /// Creates a future which copies all the bytes from one object to another.
562
- ///
563
- /// The returned future will copy all the bytes read from this `AsyncBufRead` into the
564
- /// `writer` specified. This future will only complete once the `reader` has hit
565
- /// EOF and all bytes have been written to and flushed from the `writer`
566
- /// provided.
567
- ///
568
- /// On success the number of bytes is returned.
569
- ///
570
- /// # Examples
571
- ///
572
- /// ```
573
- /// # futures::executor::block_on(async {
574
- /// use futures::io::{AsyncBufReadExt, AsyncWriteExt, Cursor};
575
- ///
576
- /// let reader = Cursor::new([1, 2, 3, 4]);
577
- /// let mut writer = Cursor::new(vec![0u8; 5]);
578
- ///
579
- /// let bytes = reader.copy_buf_into(&mut writer).await?;
580
- /// writer.close().await?;
581
- ///
582
- /// assert_eq!(bytes, 4);
583
- /// assert_eq!(writer.into_inner(), [1, 2, 3, 4, 0]);
584
- /// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
585
- /// ```
586
- fn copy_buf_into < W > ( self , writer : & mut W ) -> CopyBufInto < ' _ , Self , W >
587
- where
588
- Self : Sized ,
589
- W : AsyncWrite + Unpin + ?Sized ,
590
- {
591
- CopyBufInto :: new ( self , writer)
592
- }
593
-
594
528
/// Creates a future which will read all the bytes associated with this I/O
595
529
/// object into `buf` until the delimiter `byte` or EOF is reached.
596
530
/// This method is the async equivalent to [`BufRead::read_until`](std::io::BufRead::read_until).
0 commit comments