@@ -68,10 +68,7 @@ use libc::{EBADF, EINVAL, ENOSYS, EOPNOTSUPP, EOVERFLOW, EPERM, EXDEV};
68
68
#[ cfg( test) ]
69
69
mod tests;
70
70
71
- pub ( crate ) fn copy_spec < R : Read + ?Sized , W : Write + ?Sized > (
72
- read : & mut R ,
73
- write : & mut W ,
74
- ) -> Result < u64 > {
71
+ pub ( crate ) fn copy_spec < R : Read , W : Write > ( read : R , write : W ) -> Result < u64 > {
75
72
let copier = Copier { read, write } ;
76
73
SpecCopy :: copy ( copier)
77
74
}
@@ -160,30 +157,30 @@ fn safe_kernel_copy(source: &FdMeta, sink: &FdMeta) -> bool {
160
157
161
158
struct CopyParams ( FdMeta , Option < RawFd > ) ;
162
159
163
- struct Copier < ' a , ' b , R : Read + ? Sized , W : Write + ? Sized > {
164
- read : & ' a mut R ,
165
- write : & ' b mut W ,
160
+ struct Copier < R : Read , W : Write > {
161
+ read : R ,
162
+ write : W ,
166
163
}
167
164
168
165
trait SpecCopy {
169
166
fn copy ( self ) -> Result < u64 > ;
170
167
}
171
168
172
- impl < R : Read + ? Sized , W : Write + ? Sized > SpecCopy for Copier < ' _ , ' _ , R , W > {
169
+ impl < R : Read , W : Write > SpecCopy for Copier < R , W > {
173
170
default fn copy ( self ) -> Result < u64 > {
174
171
generic_copy ( self . read , self . write )
175
172
}
176
173
}
177
174
178
- impl < R : CopyRead , W : CopyWrite > SpecCopy for Copier < ' _ , ' _ , R , W > {
175
+ impl < R : CopyRead , W : CopyWrite > SpecCopy for Copier < R , W > {
179
176
fn copy ( self ) -> Result < u64 > {
180
- let ( reader, writer) = ( self . read , self . write ) ;
177
+ let Copier { read : mut reader, write : mut writer } = self ;
181
178
let r_cfg = reader. properties ( ) ;
182
179
let w_cfg = writer. properties ( ) ;
183
180
184
181
// before direct operations on file descriptors ensure that all source and sink buffers are empty
185
182
let mut flush = || -> crate :: io:: Result < u64 > {
186
- let bytes = reader. drain_to ( writer, u64:: MAX ) ?;
183
+ let bytes = reader. drain_to ( & mut writer, u64:: MAX ) ?;
187
184
// BufWriter buffered bytes have already been accounted for in earlier write() calls
188
185
writer. flush ( ) ?;
189
186
Ok ( bytes)
@@ -199,7 +196,7 @@ impl<R: CopyRead, W: CopyWrite> SpecCopy for Copier<'_, '_, R, W> {
199
196
200
197
if input_meta. copy_file_range_candidate ( ) && output_meta. copy_file_range_candidate ( ) {
201
198
let result = copy_regular_files ( readfd, writefd, max_write) ;
202
- result. update_take ( reader) ;
199
+ result. update_take ( & mut reader) ;
203
200
204
201
match result {
205
202
CopyResult :: Ended ( bytes_copied) => return Ok ( bytes_copied + written) ,
@@ -216,7 +213,7 @@ impl<R: CopyRead, W: CopyWrite> SpecCopy for Copier<'_, '_, R, W> {
216
213
if input_meta. potential_sendfile_source ( ) && safe_kernel_copy ( & input_meta, & output_meta)
217
214
{
218
215
let result = sendfile_splice ( SpliceMode :: Sendfile , readfd, writefd, max_write) ;
219
- result. update_take ( reader) ;
216
+ result. update_take ( & mut reader) ;
220
217
221
218
match result {
222
219
CopyResult :: Ended ( bytes_copied) => return Ok ( bytes_copied + written) ,
@@ -229,7 +226,7 @@ impl<R: CopyRead, W: CopyWrite> SpecCopy for Copier<'_, '_, R, W> {
229
226
&& safe_kernel_copy ( & input_meta, & output_meta)
230
227
{
231
228
let result = sendfile_splice ( SpliceMode :: Splice , readfd, writefd, max_write) ;
232
- result. update_take ( reader) ;
229
+ result. update_take ( & mut reader) ;
233
230
234
231
match result {
235
232
CopyResult :: Ended ( bytes_copied) => return Ok ( bytes_copied + written) ,
0 commit comments