@@ -54,6 +54,20 @@ pub trait FileExt {
54
54
#[ stable( feature = "file_offset" , since = "1.15.0" ) ]
55
55
fn read_at ( & self , buf : & mut [ u8 ] , offset : u64 ) -> io:: Result < usize > ;
56
56
57
+ /// Like `read_at`, except that it reads into a slice of buffers.
58
+ ///
59
+ /// Data is copied to fill each buffer in order, with the final buffer
60
+ /// written to possibly being only partially filled. This method must behave
61
+ /// equivalently to a single call to read with concatenated buffers.
62
+ #[ unstable( feature = "unix_file_vectored_at" , issue = "89517" ) ]
63
+ fn read_vectored_at (
64
+ & mut self ,
65
+ bufs : & mut [ io:: IoSliceMut < ' _ > ] ,
66
+ offset : u64 ,
67
+ ) -> io:: Result < usize > {
68
+ io:: default_read_vectored ( |b| self . read_at ( b, offset) , bufs)
69
+ }
70
+
57
71
/// Reads the exact number of byte required to fill `buf` from the given offset.
58
72
///
59
73
/// The offset is relative to the start of the file and thus independent
@@ -155,6 +169,16 @@ pub trait FileExt {
155
169
#[ stable( feature = "file_offset" , since = "1.15.0" ) ]
156
170
fn write_at ( & self , buf : & [ u8 ] , offset : u64 ) -> io:: Result < usize > ;
157
171
172
+ /// Like `write_at`, except that it writes from a slice of buffers.
173
+ ///
174
+ /// Data is copied from each buffer in order, with the final buffer read
175
+ /// from possibly being only partially consumed. This method must behave as
176
+ /// a call to `write_at` with the buffers concatenated would.
177
+ #[ unstable( feature = "unix_file_vectored_at" , issue = "89517" ) ]
178
+ fn write_vectored_at ( & mut self , bufs : & [ io:: IoSlice < ' _ > ] , offset : u64 ) -> io:: Result < usize > {
179
+ io:: default_write_vectored ( |b| self . write_at ( b, offset) , bufs)
180
+ }
181
+
158
182
/// Attempts to write an entire buffer starting from a given offset.
159
183
///
160
184
/// The offset is relative to the start of the file and thus independent
@@ -218,9 +242,19 @@ impl FileExt for fs::File {
218
242
fn read_at ( & self , buf : & mut [ u8 ] , offset : u64 ) -> io:: Result < usize > {
219
243
self . as_inner ( ) . read_at ( buf, offset)
220
244
}
245
+ fn read_vectored_at (
246
+ & mut self ,
247
+ bufs : & mut [ io:: IoSliceMut < ' _ > ] ,
248
+ offset : u64 ,
249
+ ) -> io:: Result < usize > {
250
+ self . as_inner ( ) . read_vectored_at ( bufs, offset)
251
+ }
221
252
fn write_at ( & self , buf : & [ u8 ] , offset : u64 ) -> io:: Result < usize > {
222
253
self . as_inner ( ) . write_at ( buf, offset)
223
254
}
255
+ fn write_vectored_at ( & mut self , bufs : & [ io:: IoSlice < ' _ > ] , offset : u64 ) -> io:: Result < usize > {
256
+ self . as_inner ( ) . write_vectored_at ( bufs, offset)
257
+ }
224
258
}
225
259
226
260
/// Unix-specific extensions to [`fs::Permissions`].
0 commit comments