1
1
use crate :: io:: util:: chain:: { chain, Chain } ;
2
2
use crate :: io:: util:: read:: { read, Read } ;
3
- use crate :: io:: util:: read_buf:: { read_buf, ReadBuf } ;
4
3
use crate :: io:: util:: read_exact:: { read_exact, ReadExact } ;
5
4
use crate :: io:: util:: read_int:: {
6
5
ReadI128 , ReadI128Le , ReadI16 , ReadI16Le , ReadI32 , ReadI32Le , ReadI64 , ReadI64Le , ReadI8 ,
@@ -13,8 +12,6 @@ use crate::io::util::read_to_string::{read_to_string, ReadToString};
13
12
use crate :: io:: util:: take:: { take, Take } ;
14
13
use crate :: io:: AsyncRead ;
15
14
16
- use bytes:: BufMut ;
17
-
18
15
cfg_io_util ! {
19
16
/// Defines numeric reader
20
17
macro_rules! read_impl {
@@ -166,71 +163,6 @@ cfg_io_util! {
166
163
read( self , buf)
167
164
}
168
165
169
- /// Pulls some bytes from this source into the specified buffer,
170
- /// advancing the buffer's internal cursor.
171
- ///
172
- /// Equivalent to:
173
- ///
174
- /// ```ignore
175
- /// async fn read_buf<B: BufMut>(&mut self, buf: &mut B) -> io::Result<usize>;
176
- /// ```
177
- ///
178
- /// Usually, only a single `read` syscall is issued, even if there is
179
- /// more space in the supplied buffer.
180
- ///
181
- /// This function does not provide any guarantees about whether it
182
- /// completes immediately or asynchronously
183
- ///
184
- /// # Return
185
- ///
186
- /// On a successful read, the number of read bytes is returned. If the
187
- /// supplied buffer is not empty and the function returns `Ok(0)` then
188
- /// the source as reached an "end-of-file" event.
189
- ///
190
- /// # Errors
191
- ///
192
- /// If this function encounters any form of I/O or other error, an error
193
- /// variant will be returned. If an error is returned then it must be
194
- /// guaranteed that no bytes were read.
195
- ///
196
- /// # Examples
197
- ///
198
- /// [`File`] implements `Read` and [`BytesMut`] implements [`BufMut`]:
199
- ///
200
- /// [`File`]: crate::fs::File
201
- /// [`BytesMut`]: bytes::BytesMut
202
- /// [`BufMut`]: bytes::BufMut
203
- ///
204
- /// ```no_run
205
- /// use tokio::fs::File;
206
- /// use tokio::io::{self, AsyncReadExt};
207
- ///
208
- /// use bytes::BytesMut;
209
- ///
210
- /// #[tokio::main]
211
- /// async fn main() -> io::Result<()> {
212
- /// let mut f = File::open("foo.txt").await?;
213
- /// let mut buffer = BytesMut::with_capacity(10);
214
- ///
215
- /// assert!(buffer.is_empty());
216
- ///
217
- /// // read up to 10 bytes, note that the return value is not needed
218
- /// // to access the data that was read as `buffer`'s internal
219
- /// // cursor is updated.
220
- /// f.read_buf(&mut buffer).await?;
221
- ///
222
- /// println!("The bytes: {:?}", &buffer[..]);
223
- /// Ok(())
224
- /// }
225
- /// ```
226
- fn read_buf<' a, B >( & ' a mut self , buf: & ' a mut B ) -> ReadBuf <' a, Self , B >
227
- where
228
- Self : Sized + Unpin ,
229
- B : BufMut ,
230
- {
231
- read_buf( self , buf)
232
- }
233
-
234
166
/// Reads the exact number of bytes required to fill `buf`.
235
167
///
236
168
/// Equivalent to:
0 commit comments